Преглед изворни кода

Fixed bug: DI losses custom method calls

XianN пре 14 година
родитељ
комит
1fa4b757a6
1 измењених фајлова са 5 додато и 2 уклоњено
  1. 5 2
      DependencyInjection/AddDependencyCallsPass.php

+ 5 - 2
DependencyInjection/AddDependencyCallsPass.php

@@ -39,8 +39,11 @@ class AddDependencyCallsPass implements CompilerPassInterface
         foreach ($container->findTaggedServiceIds('sonata.admin') as $id => $attributes) {
 
             $definition = $container->getDefinition($id);
-            $calls = array(array('setCode', array($id))) + $definition->getMethodCalls();
-            $definition->setMethodCalls($calls);
+
+            if (!$definition->hasMethodCall('setCode')) {
+                $definition->addMethodCall('setCode', array($id));
+            }
+
             $this->applyDefaults($definition, $attributes);
 
             $arguments = $definition->getArguments();