浏览代码

[Form] Introduced generic RendererInterface

Bernhard Schussek 14 年之前
父节点
当前提交
65f58c9fd1

+ 22 - 0
src/Symfony/Component/Form/Renderer/RendererInterface.php

@@ -0,0 +1,22 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Form\Renderer;
+
+interface RendererInterface
+{
+    /**
+     * Returns the rendered representation of the form
+     *
+     * @return string
+     */
+    function render();
+}

+ 6 - 1
src/Symfony/Component/Form/Renderer/ThemeRenderer.php

@@ -164,7 +164,7 @@ class ThemeRenderer implements ThemeRendererInterface, \ArrayAccess, \IteratorAg
         return $this->render('enctype', $this->vars);
     }
 
-    protected function render($part, array $vars = array())
+    protected function renderPart($part, array $vars = array())
     {
         return $this->getTheme()->render($this->blockHistory, $part, array_replace(
             $this->vars,
@@ -172,6 +172,11 @@ class ThemeRenderer implements ThemeRendererInterface, \ArrayAccess, \IteratorAg
         ));
     }
 
+    public function render(array $vars = array())
+    {
+        return $this->getWidget($vars);
+    }
+
     public function getParent()
     {
         return $this->parent;

+ 1 - 1
src/Symfony/Component/Form/Renderer/ThemeRendererInterface.php

@@ -11,7 +11,7 @@
 
 namespace Symfony\Component\Form\Renderer;
 
-interface ThemeRendererInterface
+interface ThemeRendererInterface extends RendererInterface
 {
     /**
      * Set a renderer variable that is used to render a relevant part of the attached field.