浏览代码

Avoid deprecation on DefinitionDecorator (#4560)

It was replaced by ChildDefinition on Symfony 3.3
François-Xavier de Guillebon 7 年之前
父节点
当前提交
57bb2e2955
共有 1 个文件被更改,包括 7 次插入3 次删除
  1. 7 3
      DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php

+ 7 - 3
DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php

@@ -13,6 +13,7 @@ namespace Sonata\AdminBundle\DependencyInjection\Compiler;
 
 
 use Doctrine\Common\Inflector\Inflector;
 use Doctrine\Common\Inflector\Inflector;
 use Sonata\AdminBundle\Datagrid\Pager;
 use Sonata\AdminBundle\Datagrid\Pager;
+use Symfony\Component\DependencyInjection\ChildDefinition;
 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -51,9 +52,12 @@ class AddDependencyCallsCompilerPass implements CompilerPassInterface
         foreach ($container->findTaggedServiceIds('sonata.admin') as $id => $tags) {
         foreach ($container->findTaggedServiceIds('sonata.admin') as $id => $tags) {
             foreach ($tags as $attributes) {
             foreach ($tags as $attributes) {
                 $definition = $container->getDefinition($id);
                 $definition = $container->getDefinition($id);
-                $parentDefinition = $definition instanceof DefinitionDecorator ?
-                    $container->getDefinition($definition->getParent()) :
-                    null;
+                $parentDefinition = null;
+
+                // NEXT_MAJOR: Remove check for DefinitionDecorator instance when dropping Symfony <3.3 support
+                if ($definition instanceof ChildDefinition || $definition instanceof DefinitionDecorator) {
+                    $parentDefinition = $container->getDefinition($definition->getParent());
+                }
 
 
                 $this->replaceDefaultArguments(array(
                 $this->replaceDefaultArguments(array(
                     0 => $id,
                     0 => $id,