diff --git a/DependencyInjection/Compiler/EntityListenerPass.php b/DependencyInjection/Compiler/EntityListenerPass.php index f25538d52..04b6f3d17 100644 --- a/DependencyInjection/Compiler/EntityListenerPass.php +++ b/DependencyInjection/Compiler/EntityListenerPass.php @@ -52,9 +52,9 @@ public function process(ContainerBuilder $container) $this->attachToListener($container, $name, $id, $attributes); } - if (isset($attributes['lazy']) && $attributes['lazy']) { - $listener = $container->findDefinition($id); + $listener = $container->findDefinition($id); + if ($listener->isLazy() || !empty($attributes['lazy'])) { if ($listener->isAbstract()) { throw new InvalidArgumentException(sprintf('The service "%s" must not be abstract as this entity listener is lazy-loaded.', $id)); }