From 7628b73d28cac3c073b6d50ece3979eaa1897caa Mon Sep 17 00:00:00 2001 From: Jeroen Thora Date: Tue, 21 Aug 2018 14:56:35 +0200 Subject: [PATCH] [NodeBundle] Deprecate unused TemplateEngine constructor argument (#2073) --- .../EventListener/RenderContextListener.php | 15 ++++++++++++--- .../NodeBundle/Resources/config/services.yml | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Kunstmaan/NodeBundle/EventListener/RenderContextListener.php b/src/Kunstmaan/NodeBundle/EventListener/RenderContextListener.php index 08f16299b2..e4818f31f7 100644 --- a/src/Kunstmaan/NodeBundle/EventListener/RenderContextListener.php +++ b/src/Kunstmaan/NodeBundle/EventListener/RenderContextListener.php @@ -25,10 +25,19 @@ class RenderContextListener * @param EngineInterface $templating * @param EntityManagerInterface $em */ - public function __construct(EngineInterface $templating, EntityManagerInterface $em) + public function __construct(/* EngineInterface|EntityManagerInterface */ $em, EntityManagerInterface $emOld = null) { - $this->templating = $templating; - $this->em = $em; + if ($em instanceof EngineInterface) { + // NEXT_MAJOR Also remove the symfony/templating dependency as it is unused after the removal of the templating parameter. + @trigger_error(sprintf('Passing a templating engine as the first argument of "%s" is deprecated since KunstmaanNodeBundle 5.1 and will be removed in KunstmaanNodeBundle 6.0. Remove the template engine service argument.', __METHOD__), E_USER_DEPRECATED); + + $this->templating = $em; + $this->em = $emOld; + + return; + } + + $this->em = $em; } /** diff --git a/src/Kunstmaan/NodeBundle/Resources/config/services.yml b/src/Kunstmaan/NodeBundle/Resources/config/services.yml index 1b7c5baa83..392bcdabf5 100644 --- a/src/Kunstmaan/NodeBundle/Resources/config/services.yml +++ b/src/Kunstmaan/NodeBundle/Resources/config/services.yml @@ -159,7 +159,7 @@ services: kunstmaan_node.render.context.listener: class: Kunstmaan\NodeBundle\EventListener\RenderContextListener - arguments: ['@templating', '@doctrine.orm.entity_manager'] + arguments: ['@doctrine.orm.entity_manager'] tags: - { name: kernel.event_listener, event: kernel.view, method: onKernelView }