bug #9423 [Form] fix CsrfProviderAdapter (Tobion)

This PR was merged into the master branch.

Discussion
----------

[Form] fix CsrfProviderAdapter

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Fixes   | #9418
| Tests pass?   | yes
| license?      | MIT

Commits
-------

887f71c [Form] fix CsrfProviderAdapter
This commit is contained in:
Fabien Potencier 2013-10-31 16:58:10 +01:00
commit 7455650904
2 changed files with 10 additions and 2 deletions

View File

@ -46,7 +46,7 @@ class CsrfProviderAdapter implements CsrfTokenManagerInterface
*/
public function getToken($tokenId)
{
return $this->csrfProvider->generateCsrfToken($tokenId);
return new CsrfToken($tokenId, $this->csrfProvider->generateCsrfToken($tokenId));
}
/**

View File

@ -52,12 +52,20 @@ class FormRenderer implements FormRendererInterface
*/
private $variableStack = array();
/**
* Constructor.
*
* @param FormRendererEngineInterface $engine
* @param CsrfTokenManagerInterface|null $csrfTokenManager
*
* @throws UnexpectedTypeException
*/
public function __construct(FormRendererEngineInterface $engine, $csrfTokenManager = null)
{
if ($csrfTokenManager instanceof CsrfProviderInterface) {
$csrfTokenManager = new CsrfProviderAdapter($csrfTokenManager);
} elseif (null !== $csrfTokenManager && !$csrfTokenManager instanceof CsrfTokenManagerInterface) {
throw new UnexpectedTypeException($csrfTokenManager, 'CsrfProviderInterface or CsrfTokenManagerInterface');
throw new UnexpectedTypeException($csrfTokenManager, 'CsrfProviderInterface or CsrfTokenManagerInterface or null');
}
$this->engine = $engine;