Selaa lähdekoodia

Fixed bug: DI losses custom method calls

XianN 14 vuotta sitten
vanhempi
commit
1fa4b757a6
1 muutettua tiedostoa jossa 5 lisäystä ja 2 poistoa
  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();