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?

2

Remove generation/code

Run command:

bin/magento cache:flush

bin/magento setup:di:compile

  • As I mentioned: I've deleted the generate directory, clear the cache, but I am still getting this error. – vaso123 Jun 27 '18 at 10:52
  • remove generation/code and run above command – Nikunj Vadariya Jun 27 '18 at 10:54
  • Hm, it works. Why should I recompile the di in developer mode, when I do not change any xml< – vaso123 Jun 27 '18 at 10:56
  • You should do it when you change anything related to __construct or di.xml – Nikunj Vadariya Jun 27 '18 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 Jun 27 '18 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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