Explorar o código

removed load() from EngineInterface

Fabien Potencier %!s(int64=14) %!d(string=hai) anos
pai
achega
195c971da6

+ 18 - 18
src/Symfony/Bundle/TwigBundle/TwigEngine.php

@@ -78,24 +78,6 @@ class TwigEngine implements EngineInterface
         return true;
     }
 
-    /**
-     * Loads the given template.
-     *
-     * @param mixed $name A template name
-     *
-     * @return \Twig_TemplateInterface A \Twig_TemplateInterface instance
-     *
-     * @throws \Twig_Error_Loader if the template cannot be found
-     */
-    public function load($name)
-    {
-        if ($name instanceof \Twig_Template) {
-            return $name;
-        }
-
-        return $this->environment->loadTemplate($this->parser->parse($name), is_array($name) ? json_encode($name) : $name);
-    }
-
     /**
      * Returns true if this class is able to render the given template.
      *
@@ -133,4 +115,22 @@ class TwigEngine implements EngineInterface
 
         return $response;
     }
+
+    /**
+     * Loads the given template.
+     *
+     * @param mixed $name A template name
+     *
+     * @return \Twig_TemplateInterface A \Twig_TemplateInterface instance
+     *
+     * @throws \Twig_Error_Loader if the template cannot be found
+     */
+    protected function load($name)
+    {
+        if ($name instanceof \Twig_Template) {
+            return $name;
+        }
+
+        return $this->environment->loadTemplate($this->parser->parse($name), is_array($name) ? json_encode($name) : $name);
+    }
 }

+ 0 - 11
src/Symfony/Component/Templating/EngineInterface.php

@@ -50,17 +50,6 @@ interface EngineInterface
      */
     function exists($name);
 
-    /**
-     * Loads the given template.
-     *
-     * @param string $name A template name
-     *
-     * @return mixed A renderable template
-     *
-     * @throws \Exception if the template cannot be found
-     */
-    function load($name);
-
     /**
      * Returns true if this class is able to render the given template.
      *

+ 28 - 28
src/Symfony/Component/Templating/PhpEngine.php

@@ -120,34 +120,6 @@ class PhpEngine implements EngineInterface, \ArrayAccess
         return true;
     }
 
-    /**
-     * Loads the given template.
-     *
-     * @param mixed $name A template name
-     *
-     * @return Storage A Storage instance
-     *
-     * @throws \InvalidArgumentException if the template cannot be found
-     */
-    public function load($name)
-    {
-        $template = $this->parser->parse($name);
-
-        $key = md5(serialize($template));
-        if (isset($this->cache[$key])) {
-            return $this->cache[$key];
-        }
-
-        // load
-        $template = $this->loader->load($template);
-
-        if (false === $template) {
-            throw new \InvalidArgumentException(sprintf('The template "%s" does not exist.', $name));
-        }
-
-        return $this->cache[$key] = $template;
-    }
-
     /**
      * Returns true if this class is able to render the given template.
      *
@@ -488,4 +460,32 @@ class PhpEngine implements EngineInterface, \ArrayAccess
     {
         return $this->loader;
     }
+
+    /**
+     * Loads the given template.
+     *
+     * @param mixed $name A template name
+     *
+     * @return Storage A Storage instance
+     *
+     * @throws \InvalidArgumentException if the template cannot be found
+     */
+    protected function load($name)
+    {
+        $template = $this->parser->parse($name);
+
+        $key = md5(serialize($template));
+        if (isset($this->cache[$key])) {
+            return $this->cache[$key];
+        }
+
+        // load
+        $template = $this->loader->load($template);
+
+        if (false === $template) {
+            throw new \InvalidArgumentException(sprintf('The template "%s" does not exist.', $name));
+        }
+
+        return $this->cache[$key] = $template;
+    }
 }