From 4f5b44bd3bd490309eb2ba7b44df4769816ba729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sat, 3 Aug 2013 19:26:54 +0200 Subject: twig implementation --- .../Component/Form/FormRendererInterface.php | 103 +++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 vendor/symfony/form/Symfony/Component/Form/FormRendererInterface.php (limited to 'vendor/symfony/form/Symfony/Component/Form/FormRendererInterface.php') diff --git a/vendor/symfony/form/Symfony/Component/Form/FormRendererInterface.php b/vendor/symfony/form/Symfony/Component/Form/FormRendererInterface.php new file mode 100644 index 00000000..848e7125 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/FormRendererInterface.php @@ -0,0 +1,103 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form; + +/** + * Renders a form into HTML. + * + * @author Bernhard Schussek + */ +interface FormRendererInterface +{ + /** + * Returns the engine used by this renderer. + * + * @return FormRendererEngineInterface The renderer engine. + */ + public function getEngine(); + + /** + * Sets the theme(s) to be used for rendering a view and its children. + * + * @param FormView $view The view to assign the theme(s) to. + * @param mixed $themes The theme(s). The type of these themes + * is open to the implementation. + */ + public function setTheme(FormView $view, $themes); + + /** + * Renders a named block of the form theme. + * + * @param FormView $view The view for which to render the block. + * @param string $blockName The name of the block. + * @param array $variables The variables to pass to the template. + * + * @return string The HTML markup + */ + public function renderBlock(FormView $view, $blockName, array $variables = array()); + + /** + * Searches and renders a block for a given name suffix. + * + * The block is searched by combining the block names stored in the + * form view with the given suffix. If a block name is found, that + * block is rendered. + * + * If this method is called recursively, the block search is continued + * where a block was found before. + * + * @param FormView $view The view for which to render the block. + * @param string $blockNameSuffix The suffix of the block name. + * @param array $variables The variables to pass to the template. + * + * @return string The HTML markup + */ + public function searchAndRenderBlock(FormView $view, $blockNameSuffix, array $variables = array()); + + /** + * Renders a CSRF token. + * + * Use this helper for CSRF protection without the overhead of creating a + * form. + * + * + * + * + * + * Check the token in your action using the same intention. + * + * + * $csrfProvider = $this->get('form.csrf_provider'); + * if (!$csrfProvider->isCsrfTokenValid('rm_user_'.$user->getId(), $token)) { + * throw new \RuntimeException('CSRF attack detected.'); + * } + * + * + * @param string $intention The intention of the protected action + * + * @return string A CSRF token + */ + public function renderCsrfToken($intention); + + /** + * Makes a technical name human readable. + * + * Sequences of underscores are replaced by single spaces. The first letter + * of the resulting string is capitalized, while all other letters are + * turned to lowercase. + * + * @param string $text The text to humanize. + * + * @return string The humanized text. + */ + public function humanize($text); +} -- cgit v1.2.3