]> git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/symfony/form/Symfony/Component/Form/FormRendererInterface.php
twig implementation
[github/wallabag/wallabag.git] / vendor / symfony / form / Symfony / Component / Form / FormRendererInterface.php
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Form;
13
14 /**
15 * Renders a form into HTML.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19 interface FormRendererInterface
20 {
21 /**
22 * Returns the engine used by this renderer.
23 *
24 * @return FormRendererEngineInterface The renderer engine.
25 */
26 public function getEngine();
27
28 /**
29 * Sets the theme(s) to be used for rendering a view and its children.
30 *
31 * @param FormView $view The view to assign the theme(s) to.
32 * @param mixed $themes The theme(s). The type of these themes
33 * is open to the implementation.
34 */
35 public function setTheme(FormView $view, $themes);
36
37 /**
38 * Renders a named block of the form theme.
39 *
40 * @param FormView $view The view for which to render the block.
41 * @param string $blockName The name of the block.
42 * @param array $variables The variables to pass to the template.
43 *
44 * @return string The HTML markup
45 */
46 public function renderBlock(FormView $view, $blockName, array $variables = array());
47
48 /**
49 * Searches and renders a block for a given name suffix.
50 *
51 * The block is searched by combining the block names stored in the
52 * form view with the given suffix. If a block name is found, that
53 * block is rendered.
54 *
55 * If this method is called recursively, the block search is continued
56 * where a block was found before.
57 *
58 * @param FormView $view The view for which to render the block.
59 * @param string $blockNameSuffix The suffix of the block name.
60 * @param array $variables The variables to pass to the template.
61 *
62 * @return string The HTML markup
63 */
64 public function searchAndRenderBlock(FormView $view, $blockNameSuffix, array $variables = array());
65
66 /**
67 * Renders a CSRF token.
68 *
69 * Use this helper for CSRF protection without the overhead of creating a
70 * form.
71 *
72 * <code>
73 * <input type="hidden" name="token" value="<?php $renderer->renderCsrfToken('rm_user_'.$user->getId()) ?>">
74 * </code>
75 *
76 * Check the token in your action using the same intention.
77 *
78 * <code>
79 * $csrfProvider = $this->get('form.csrf_provider');
80 * if (!$csrfProvider->isCsrfTokenValid('rm_user_'.$user->getId(), $token)) {
81 * throw new \RuntimeException('CSRF attack detected.');
82 * }
83 * </code>
84 *
85 * @param string $intention The intention of the protected action
86 *
87 * @return string A CSRF token
88 */
89 public function renderCsrfToken($intention);
90
91 /**
92 * Makes a technical name human readable.
93 *
94 * Sequences of underscores are replaced by single spaces. The first letter
95 * of the resulting string is capitalized, while all other letters are
96 * turned to lowercase.
97 *
98 * @param string $text The text to humanize.
99 *
100 * @return string The humanized text.
101 */
102 public function humanize($text);
103 }