Explorar el Código

made a slight optimization

Fabien Potencier hace 14 años
padre
commit
a40d317f49

+ 4 - 18
src/Symfony/Bundle/FrameworkBundle/Templating/Engine.php

@@ -30,17 +30,17 @@ class Engine extends BaseEngine
      *
      * @param ContainerInterface $container A ContainerInterface instance
      * @param LoaderInterface    $loader    A loader instance
-     * @param array              $renderers An array of renderer instances
      */
-    public function __construct(ContainerInterface $container, LoaderInterface $loader, array $renderers = array())
+    public function __construct(ContainerInterface $container, LoaderInterface $loader)
     {
         $this->container = $container;
 
-        parent::__construct($loader, $renderers);
+        parent::__construct($loader);
 
         foreach ($this->container->findTaggedServiceIds('templating.renderer') as $id => $attributes) {
             if (isset($attributes[0]['alias'])) {
-                $this->renderers[$attributes[0]['alias']] = $id;
+                $this->renderers[$attributes[0]['alias']] = $this->container->get($id);
+                $this->renderers[$attributes[0]['alias']]->setEngine($this);
             }
         }
 
@@ -52,20 +52,6 @@ class Engine extends BaseEngine
         }
     }
 
-    public function render($name, array $parameters = array())
-    {
-        list(, $options) = $this->splitTemplateName($name);
-
-        $renderer = $options['renderer'];
-
-        if (isset($this->renderers[$renderer]) && is_string($this->renderers[$renderer])) {
-            $this->renderers[$renderer] = $this->container->get($this->renderers[$renderer]);
-            $this->renderers[$renderer]->setEngine($this);
-        }
-
-        return parent::render($name, $parameters);
-    }
-
     /**
      * Renders a view and returns a Response.
      *

+ 1 - 2
src/Symfony/Bundle/TwigBundle/Extension/TemplatingExtension.php

@@ -30,7 +30,6 @@ class TemplatingExtension extends \Twig_Extension
     public function __construct(ContainerInterface $container)
     {
         $this->container = $container;
-        $this->templating = $container->get('templating.engine');
     }
 
     public function getContainer()
@@ -40,7 +39,7 @@ class TemplatingExtension extends \Twig_Extension
 
     public function getTemplating()
     {
-        return $this->templating;
+        return $this->container->get('templating.engine');
     }
 
     /**