Переглянути джерело

[WebBundle] added a way to add more renderer to the Templating Engine from the container

Fabien Potencier 15 роки тому
батько
коміт
8cd2b45004

+ 8 - 2
src/Symfony/Framework/WebBundle/Templating/Engine.php

@@ -40,12 +40,18 @@ class Engine extends BaseEngine
      */
     public function __construct(ContainerInterface $container, LoaderInterface $loader, array $renderers = array(), $escaper)
     {
-        parent::__construct($loader, $renderers);
-
         $this->level = 0;
         $this->container = $container;
         $this->escaper = $escaper;
 
+        foreach ($this->container->findAnnotatedServiceIds('templating.renderer') as $id => $attributes) {
+            if (isset($attributes[0]['alias'])) {
+                $renderers[$attributes[0]['alias']] = $this->container->getService($id);
+            }
+        }
+
+        parent::__construct($loader, $renderers);
+
         $this->helpers = array();
         foreach ($this->container->findAnnotatedServiceIds('templating.helper') as $id => $attributes) {
             if (isset($attributes[0]['alias'])) {