This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Form/FormRendererInterface.php
Fabien Potencier 56b0139b0d Merge branch '2.3' into 2.4
* 2.3:
  Validate locales sets intos translator
  Fix UserPassword validator translation
  Remove Spaceless Blocks from Twig Form Templates
  fixed typo
  [HttpFoundation] Fix to prevent magic bytes injection in JSONP responses (Prevents CVE-2014-4671)
  added regression test
  fix issue #8171 on configuration tree for twig extension -- pairing up with @cordoval
  [HttpFoundation] Fix wrong assertion in Response test
  [Upgrade] Fixed markdown syntax
  [2.3][Form] Cleanup & fix phpdocs

Conflicts:
	src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
	src/Symfony/Component/Form/Extension/Core/ChoiceList/SimpleChoiceList.php
	src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
2014-07-15 16:07:10 +02:00

104 lines
3.2 KiB
PHP

<?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.
*
* @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.
*
* <code>
* <input type="hidden" name="token" value="<?php $renderer->renderCsrfToken('rm_user_'.$user->getId()) ?>">
* </code>
*
* Check the token in your action using the same token ID.
*
* <code>
* $csrfProvider = $this->get('security.csrf.token_generator');
* if (!$csrfProvider->isCsrfTokenValid('rm_user_'.$user->getId(), $token)) {
* throw new \RuntimeException('CSRF attack detected.');
* }
* </code>
*
* @param string $tokenId The ID of the CSRF token
*
* @return string A CSRF token
*/
public function renderCsrfToken($tokenId);
/**
* 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);
}