Ver Fonte

moved integration between the Translation component and Twig to a Symfony Bridge

Fabien Potencier há 14 anos atrás
pai
commit
e912b347f0

+ 5 - 4
src/Symfony/Bundle/TwigBundle/Extension/TransExtension.php

@@ -9,19 +9,20 @@
  * file that was distributed with this source code.
  */
 
-namespace Symfony\Bundle\TwigBundle\Extension;
+namespace Symfony\Bridge\Twig\Extension;
 
-use Symfony\Bundle\TwigBundle\TokenParser\TransTokenParser;
-use Symfony\Bundle\TwigBundle\TokenParser\TransChoiceTokenParser;
+use Symfony\Bridge\Twig\TokenParser\TransTokenParser;
+use Symfony\Bridge\Twig\TokenParser\TransChoiceTokenParser;
 use Symfony\Component\Translation\TranslatorInterface;
 
 /**
+ * Provides integration of the Translation component with Twig.
  *
  * @author Fabien Potencier <fabien@symfony.com>
  */
 class TransExtension extends \Twig_Extension
 {
-    protected $translator;
+    private $translator;
 
     public function __construct(TranslatorInterface $translator)
     {

+ 1 - 1
src/Symfony/Bundle/TwigBundle/Node/TransNode.php

@@ -9,7 +9,7 @@
  * file that was distributed with this source code.
  */
 
-namespace Symfony\Bundle\TwigBundle\Node;
+namespace Symfony\Bridge\Twig\Node;
 
 /**
  * 

+ 2 - 2
src/Symfony/Bundle/TwigBundle/TokenParser/TransChoiceTokenParser.php

@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace Symfony\Bundle\TwigBundle\TokenParser;
+namespace Symfony\Bridge\Twig\TokenParser;
 
-use Symfony\Bundle\TwigBundle\Node\TransNode;
+use Symfony\Bridge\Twig\Node\TransNode;
 
 /**
  * 

+ 2 - 2
src/Symfony/Bundle/TwigBundle/TokenParser/TransTokenParser.php

@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace Symfony\Bundle\TwigBundle\TokenParser;
+namespace Symfony\Bridge\Twig\TokenParser;
 
-use Symfony\Bundle\TwigBundle\Node\TransNode;
+use Symfony\Bridge\Twig\Node\TransNode;
 
 /**
  * 

+ 1 - 1
src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml

@@ -33,7 +33,7 @@
             <argument type="service" id="templating.globals" />
         </service>
 
-        <service id="twig.extension.trans" class="Symfony\Bundle\TwigBundle\Extension\TransExtension" public="false">
+        <service id="twig.extension.trans" class="Symfony\Bridge\Twig\Extension\TransExtension" public="false">
             <tag name="twig.extension" />
             <argument type="service" id="translator" />
         </service>

+ 22 - 0
tests/Symfony/Tests/Bridge/Twig/TestCase.php

@@ -0,0 +1,22 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Tests\Bridge\Twig;
+
+class TestCase extends \PHPUnit_Framework_TestCase
+{
+    protected function setUp()
+    {
+        if (!class_exists('Twig_Environment')) {
+            $this->markTestSkipped('Twig is not available.');
+        }
+    }
+}

+ 9 - 3
src/Symfony/Bundle/TwigBundle/Tests/TransTest.php

@@ -9,15 +9,21 @@
  * file that was distributed with this source code.
  */
 
-namespace Symfony\Bundle\TwigBundle\Tests;
+namespace Symfony\Tests\Bridge\Twig;
 
-use Symfony\Bundle\TwigBundle\Tests\TestCase;
-use Symfony\Bundle\TwigBundle\Extension\TransExtension;
+use Symfony\Bridge\Twig\Extension\TransExtension;
 use Symfony\Component\Translation\Translator;
 use Symfony\Component\Translation\MessageSelector;
 
 class TransTest extends TestCase
 {
+    protected function setUp()
+    {
+        if (!class_exists('Twig_Environment')) {
+            $this->markTestSkipped('Twig is not available.');
+        }
+    }
+
     /**
      * @dataProvider getTransTests
      */