2012-07-15 17:58:13 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the Symfony package.
|
|
|
|
*
|
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
|
|
*
|
|
|
|
* 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 <bschussek@gmail.com>
|
|
|
|
*/
|
|
|
|
interface FormRendererInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Returns the engine used by this renderer.
|
|
|
|
*
|
2016-06-28 06:50:50 +01:00
|
|
|
* @return FormRendererEngineInterface The renderer engine
|
2012-07-15 17:58:13 +01:00
|
|
|
*/
|
|
|
|
public function getEngine();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the theme(s) to be used for rendering a view and its children.
|
|
|
|
*
|
2017-05-02 11:14:20 +01:00
|
|
|
* @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.
|
|
|
|
* @param bool $useDefaultThemes If true, will use default themes specified
|
2017-10-19 16:12:11 +01:00
|
|
|
* in the renderer
|
2012-07-15 17:58:13 +01:00
|
|
|
*/
|
2017-10-19 16:12:11 +01:00
|
|
|
public function setTheme(FormView $view, $themes, $useDefaultThemes = true);
|
2012-07-15 17:58:13 +01:00
|
|
|
|
|
|
|
/**
|
2012-07-21 18:44:09 +01:00
|
|
|
* Renders a named block of the form theme.
|
2012-07-15 17:58:13 +01:00
|
|
|
*
|
2016-06-28 06:50:50 +01:00
|
|
|
* @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
|
2012-07-15 17:58:13 +01:00
|
|
|
*
|
|
|
|
* @return string The HTML markup
|
|
|
|
*/
|
2019-01-16 09:39:14 +00:00
|
|
|
public function renderBlock(FormView $view, $blockName, array $variables = []);
|
2012-07-15 17:58:13 +01:00
|
|
|
|
|
|
|
/**
|
2012-07-21 18:44:09 +01:00
|
|
|
* Searches and renders a block for a given name suffix.
|
2012-07-15 17:58:13 +01:00
|
|
|
*
|
2012-07-21 18:44:09 +01:00
|
|
|
* 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.
|
2012-07-15 17:58:13 +01:00
|
|
|
*
|
2012-07-21 18:44:09 +01:00
|
|
|
* If this method is called recursively, the block search is continued
|
|
|
|
* where a block was found before.
|
2012-07-15 17:58:13 +01:00
|
|
|
*
|
2016-06-28 06:50:50 +01:00
|
|
|
* @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
|
2012-07-15 17:58:13 +01:00
|
|
|
*
|
|
|
|
* @return string The HTML markup
|
|
|
|
*/
|
2019-01-16 09:39:14 +00:00
|
|
|
public function searchAndRenderBlock(FormView $view, $blockNameSuffix, array $variables = []);
|
2012-07-15 17:58:13 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders a CSRF token.
|
|
|
|
*
|
|
|
|
* Use this helper for CSRF protection without the overhead of creating a
|
|
|
|
* form.
|
|
|
|
*
|
2018-08-28 22:39:52 +01:00
|
|
|
* <input type="hidden" name="token" value="<?php $renderer->renderCsrfToken('rm_user_'.$user->getId()) ?>">
|
2012-07-15 17:58:13 +01:00
|
|
|
*
|
2013-09-27 08:37:01 +01:00
|
|
|
* Check the token in your action using the same token ID.
|
2012-07-15 17:58:13 +01:00
|
|
|
*
|
2018-09-02 18:11:59 +01:00
|
|
|
* // $csrfProvider being an instance of Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface
|
2018-08-28 22:39:52 +01:00
|
|
|
* if (!$csrfProvider->isCsrfTokenValid('rm_user_'.$user->getId(), $token)) {
|
|
|
|
* throw new \RuntimeException('CSRF attack detected.');
|
|
|
|
* }
|
2012-07-15 17:58:13 +01:00
|
|
|
*
|
2013-09-27 08:37:01 +01:00
|
|
|
* @param string $tokenId The ID of the CSRF token
|
2012-07-15 17:58:13 +01:00
|
|
|
*
|
|
|
|
* @return string A CSRF token
|
|
|
|
*/
|
2013-09-27 08:37:01 +01:00
|
|
|
public function renderCsrfToken($tokenId);
|
2012-07-15 17:58:13 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
2016-06-28 06:50:50 +01:00
|
|
|
* @param string $text The text to humanize
|
2012-07-15 17:58:13 +01:00
|
|
|
*
|
2016-06-28 06:50:50 +01:00
|
|
|
* @return string The humanized text
|
2012-07-15 17:58:13 +01:00
|
|
|
*/
|
|
|
|
public function humanize($text);
|
|
|
|
}
|