Form\TwigRenderer (Bridge\Twig)
Symfony\Bridge\Twig\Form\TwigRenderer
class TwigRenderer extends FormRenderer implements TwigRendererInterface
Constants
CACHE_KEY_VAR |
Methods
__construct(TwigRendererEngineInterface $engine, CsrfTokenManagerInterface|null $csrfTokenManager = null) Constructor. | ||
FormRendererEngineInterface | getEngine() Returns the engine used by this renderer. | from FormRenderer |
setTheme(FormView $view, mixed $themes) Sets the theme(s) to be used for rendering a view and its children. | from FormRenderer | |
string | renderCsrfToken(string $tokenId) Renders a CSRF token. | from FormRenderer |
string | renderBlock(FormView $view, string $blockName, array $variables = array()) Renders a named block of the form theme. | from FormRenderer |
string | searchAndRenderBlock(FormView $view, string $blockNameSuffix, array $variables = array()) Searches and renders a block for a given name suffix. | from FormRenderer |
string | humanize(string $text) Makes a technical name human readable. | from FormRenderer |
setEnvironment(Twig_Environment $environment) Sets Twig's environment. |
Details
public __construct(TwigRendererEngineInterface $engine, CsrfTokenManagerInterface|null $csrfTokenManager = null)
Constructor.
public FormRendererEngineInterface getEngine()
Returns the engine used by this renderer.
public setTheme(FormView $view, mixed $themes)
Sets the theme(s) to be used for rendering a view and its children.
public string renderCsrfToken(string $tokenId)
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 token ID.
$csrfProvider = $this->get('security.csrf.tokengenerator');
if (!$csrfProvider->isCsrfTokenValid('rmuser_'.$user->getId(), $token)) {
throw new \RuntimeException('CSRF attack detected.');
}
public string renderBlock(FormView $view, string $blockName, array $variables = array())
Renders a named block of the form theme.
public string searchAndRenderBlock(FormView $view, string $blockNameSuffix, 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.
public string humanize(string $text)
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.
public setEnvironment(Twig_Environment $environment)
Sets Twig's environment.
© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/3.0/Symfony/Bridge/Twig/Form/TwigRenderer.html