简体   繁体   中英

Argument 1 passed to Twig_Extensions_Extension_Date::__construct() must implement interface TranslatorInterface

Can someone please help me with this error.

Type error: Argument 1 passed to Twig_Extensions_Extension_Date::__construct() must implement interface Symfony\\Component\\Translation\\TranslatorInterface, instance of VojtaSvoboda\\TwigExtensions\\Classes\\TimeDiffTranslator given, called in plugins\\vojtasvoboda\\twigextensions\\

All I know from this message is that the getTimeFilter method in vojtasvoboda\\twigextensions\\Plugin.php is passing a parameter of type 'time_diff_traslator' but the required type is TranslatorInterface.

$translator = $this->app->make('time_diff_translator'); $timeExtension = new Twig_Extensions_Extension_Date($translator);

Below is the constructor for Twig_Extensions_Extension_Date and you can see its taking a parameter of type TranslatorInterface but Plugin.php is passing a different parameter. /** * @var TranslatorInterface */ private $translator;

public function __construct(TranslatorInterface $translator = null)
{
    $this->translator = $translator;
}

/**
 * {@inheritdoc}

I would suggest to update your plugin as in old version you can see in git diff , they are not implemented interface ( https://github.com/vojtasvoboda/oc-twigextensions-plugin/commit/e6feb178d40ee0d000d0a6f7d2462d6d70e4194e#diff-325d760197f3aac320381cc8ddd52660 )

in new version they have implemented proper interface so with new version it should work.

Old code in repo

class TimeDiffTranslator extends Translator

New code in repo

...
use Symfony\Component\Translation\TranslatorInterface;
...           
TimeDiffTranslator extends Translator implements TranslatorInterface

so if you update your extension with new code TimeDiffTranslator is type of TranslatorInterface and constructor will accept it, use direct October cms back-end or use git repository to update your plugin.

Update


Please follow given screen shot and you can update your october cms version as well all plugins (make sure you didn't do any core changes as well market place plugin changes as this update will override them)

go to settings - plugin and updates 图片1

check for update image2

apply update iamge3

please let me know if its not working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM