1

I just want to inject an object into my plugin.

/* @var \Magento\Checkout\Model\Session */
protected $session;

public function __construct(\Magento\Checkout\Model\Session $session)
{
    $this->session = $session;
}

For some reason, I get an error message:

Fatal error: Uncaught TypeError: Argument 1 passed to Company\Modul\Plugin\Checkout\LayoutProcessorPlugin::__construct() must be an instance of Magento\Checkout\Model\Session, none given, called in ...

I've deleted the generate directory, clear the cache, but I am still getting this error.

Why is it?

1

1 Answer 1

2

Remove generation/code

Run command:

bin/magento cache:flush

bin/magento setup:di:compile

6
  • As I mentioned: I've deleted the generate directory, clear the cache, but I am still getting this error.
    – vaso123
    Commented Jun 27, 2018 at 10:52
  • remove generation/code and run above command Commented Jun 27, 2018 at 10:54
  • Hm, it works. Why should I recompile the di in developer mode, when I do not change any xml<
    – vaso123
    Commented Jun 27, 2018 at 10:56
  • You should do it when you change anything related to __construct or di.xml Commented Jun 27, 2018 at 11:06
  • As a sidenote if your website is in developer mode, it is sufficient to just use 1 command: magento setup:upgrade
    – Menno
    Commented Jun 27, 2018 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.