Explorar el Código

fix Circular reference error

Thomas hace 14 años
padre
commit
135d28205e

+ 0 - 1
DependencyInjection/BaseApplicationExtension.php

@@ -41,7 +41,6 @@ class BaseApplicationExtension extends Extension
         // register the twig extension
         $container
             ->register('twig.extension.base_application', 'Bundle\Sonata\BaseApplicationBundle\Twig\Extension\BaseApplicationExtension')
-            ->addMethodCall('setTemplating', array(new Reference('templating')))
             ->addTag('twig.extension');
 
         // registers crud action

+ 17 - 3
Twig/Extension/BaseApplicationExtension.php

@@ -18,6 +18,14 @@ class BaseApplicationExtension extends \Twig_Extension
 
     protected $templating;
 
+    /**
+     * {@inheritdoc}
+     */
+    public function initRuntime(\Twig_Environment $environment)
+    {
+        $this->environment = $environment;
+    }
+
     /**
      * Returns a list of filters to add to the existing list.
      *
@@ -63,7 +71,9 @@ class BaseApplicationExtension extends \Twig_Extension
             
         }
 
-        return $this->templating->render($field_description['template'], array_merge($params, array(
+        $template = $this->environment->loadTemplate($field_description['template']);
+
+        return $template->render(array_merge($params, array(
             'object' => $object,
             'value'  => $value,
             'field_description' => $field_description
@@ -74,7 +84,9 @@ class BaseApplicationExtension extends \Twig_Extension
     {
         $description = $filter->getDescription();
 
-        return $this->templating->render($description['template'], array_merge($params, array(
+        $template = $this->environment->loadTemplate($description['template']);
+
+        return $template->render(array_merge($params, array(
             'filter' => $filter
         )));
     }
@@ -92,7 +104,9 @@ class BaseApplicationExtension extends \Twig_Extension
             return '';
         }
 
-        return $this->templating->render($field_description['template'], array_merge($params, array(
+        $template = $this->environment->loadTemplate($field_description['template']);
+        
+        return $template->render(array_merge($params, array(
             'object'            => $object,
             'field_description' => $field_description,
             'field_element'     => $form->get($field_description['fieldName']),