This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » eZ Publish 5 Platform » Using LegacyKernel in service

Using LegacyKernel in service

Using LegacyKernel in service

Wednesday 15 January 2014 11:18:30 am - 2 replies

Hello folks!

I would like to use the LegacyKernel in my service. I found an example here to use LegacyKernel in a workflow. I copied the part where the LegacyKernel is used and implemented it in my code.

After that I add the following to my arguments array in my service.yml

 - @ezpublish_legacy.kernel

After that I edited the constructor of my service like this:

In the use block I added this

use eZ\Publish\Core\MVC\Legacy\Kernel as LegacyKernel;

and in my construtor this:

    public function __construct( Repository $repository, Html5 $html5Converter, LegacyKernel $legacyKernel, array $settings = array())
        //some code
        $this->legacyKernel = $legacyKernel;
        // a bit more code

Sadly it doenst work and in the documentation at I cant find any tutorial to add the LegacyKernel in my service. sad.gif Emoticon

When I try to run my code I get this error message:

Catchable Fatal Error: Argument 3 passed to test\MyBundle\Core\Repository\CalendarService::__construct() must be an instance of eZ\Publish\Core\MVC\Legacy\Kernel, instance of Closure given, called in /var/vhosts/ on line 5277 and defined in /var/vhosts/ line 64

I cant find anything related to this in the web so I hope someone can give me a hint to solve this problem.



Wednesday 15 January 2014 1:06:44 pm

Hi Tim

Legacy kernel is always passed as a closure to be correctly lazy loaded. Hence you need to change your constructor to receive \Closure instead of LegacyKernel.

Then you'll need to run the closure on demand. You'll find a full example in LegacySetupController.

Hope this helps happy.gif Emoticon

Wednesday 15 January 2014 2:28:31 pm

Hi Jérôme,

thank you for your help! I changed the constructor and checked out the example and now it works!

Thank you very much!


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from