Forráskód Böngészése

Accept translator defined as service without alias (#4532)

Translator can be disabled in the FrameworkBundle config.
In this case an IdentityTranslator (that does nothing) is
still registered by the FrameworkBundle as a "translator"
service (but as not an alias).

This commit makes Sonata Admin accepts any "translator"
service (being an alias or not).
Loïck Piera 8 éve
szülő
commit
b5b821618a

+ 1 - 1
DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php

@@ -34,7 +34,7 @@ class AddDependencyCallsCompilerPass implements CompilerPassInterface
     public function process(ContainerBuilder $container)
     public function process(ContainerBuilder $container)
     {
     {
         // check if translator service exist
         // check if translator service exist
-        if (!$container->hasAlias('translator')) {
+        if (!$container->has('translator')) {
             throw new \RuntimeException('The "translator" service is not yet enabled.
             throw new \RuntimeException('The "translator" service is not yet enabled.
                 It\'s required by SonataAdmin to display all labels properly.
                 It\'s required by SonataAdmin to display all labels properly.
 
 

+ 1 - 0
Tests/DependencyInjection/Compiler/AddDependencyCallsCompilerPassTest.php

@@ -49,6 +49,7 @@ class AddDependencyCallsCompilerPassTest extends PHPUnit_Framework_TestCase
 
 
         $container = $this->getContainer();
         $container = $this->getContainer();
         $container->removeAlias('translator');
         $container->removeAlias('translator');
+        $container->removeDefinition('translator');
         $this->extension->load(array($this->config), $container);
         $this->extension->load(array($this->config), $container);
 
 
         $compilerPass = new AddDependencyCallsCompilerPass();
         $compilerPass = new AddDependencyCallsCompilerPass();