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

Remove checks for existing translator

To use SonataAdminBundle, the translator service has to be enabled. It
is always injected in the admin by a compiler pass, which means there is
no point (anymore?) in checking it exists.
Closes #4089
Grégoire Paris 8 éve
szülő
commit
fa3911ddec
2 módosított fájl, 0 hozzáadás és 22 törlés
  1. 0 8
      Admin/AbstractAdmin.php
  2. 0 14
      Tests/Admin/AdminTest.php

+ 0 - 8
Admin/AbstractAdmin.php

@@ -2109,10 +2109,6 @@ EOT;
     {
         $domain = $domain ?: $this->getTranslationDomain();
 
-        if (!$this->translator) {
-            return $id;
-        }
-
         return $this->translator->trans($id, $parameters, $domain, $locale);
     }
 
@@ -2131,10 +2127,6 @@ EOT;
     {
         $domain = $domain ?: $this->getTranslationDomain();
 
-        if (!$this->translator) {
-            return $id;
-        }
-
         return $this->translator->transChoice($id, $count, $parameters, $domain, $locale);
     }
 

+ 0 - 14
Tests/Admin/AdminTest.php

@@ -1192,13 +1192,6 @@ class AdminTest extends \PHPUnit_Framework_TestCase
         $this->assertSame('sonata.post.admin.post', $admin->getObjectIdentifier());
     }
 
-    public function testTransWithNoTranslator()
-    {
-        $admin = new PostAdmin('sonata.post.admin.post', 'NewsBundle\Entity\Post', 'SonataNewsBundle:PostAdmin');
-
-        $this->assertSame('foo', $admin->trans('foo'));
-    }
-
     public function testTrans()
     {
         $admin = new PostAdmin('sonata.post.admin.post', 'NewsBundle\Entity\Post', 'SonataNewsBundle:PostAdmin');
@@ -1230,13 +1223,6 @@ class AdminTest extends \PHPUnit_Framework_TestCase
         $this->assertSame('fooTranslated', $admin->trans('foo', array('name' => 'Andrej'), 'fooMessageDomain'));
     }
 
-    public function testTransChoiceWithNoTranslator()
-    {
-        $admin = new PostAdmin('sonata.post.admin.post', 'NewsBundle\Entity\Post', 'SonataNewsBundle:PostAdmin');
-
-        $this->assertSame('foo', $admin->transChoice('foo', 2));
-    }
-
     public function testTransChoice()
     {
         $admin = new PostAdmin('sonata.post.admin.post', 'NewsBundle\Entity\Post', 'SonataNewsBundle:PostAdmin');