Вход Регистрация
Файл: symfony-2.7/src/Symfony/Bridge/Twig/Form/TwigRenderer.php
Строк: 123
<?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 SymfonyBridgeTwigForm;

use 
SymfonyComponentFormExceptionUnexpectedTypeException;
use 
SymfonyComponentFormExtensionCsrfCsrfProviderCsrfProviderAdapter;
use 
SymfonyComponentFormExtensionCsrfCsrfProviderCsrfProviderInterface;
use 
SymfonyComponentFormFormRenderer;
use 
SymfonyComponentSecurityCsrfCsrfTokenManagerInterface;

/**
 * @author Bernhard Schussek <bschussek@gmail.com>
 */
class TwigRenderer extends FormRenderer implements TwigRendererInterface
{
    
/**
     * @var TwigRendererEngineInterface
     */
    
private $engine;

    public function 
__construct(TwigRendererEngineInterface $engine$csrfTokenManager null)
    {
        if (
$csrfTokenManager instanceof CsrfProviderInterface) {
            
$csrfTokenManager = new CsrfProviderAdapter($csrfTokenManager);
        } elseif (
null !== $csrfTokenManager && !$csrfTokenManager instanceof CsrfTokenManagerInterface) {
            throw new 
UnexpectedTypeException($csrfTokenManager'CsrfProviderInterface or CsrfTokenManagerInterface');
        }

        
parent::__construct($engine$csrfTokenManager);

        
$this->engine $engine;
    }

    
/**
     * {@inheritdoc}
     */
    
public function setEnvironment(Twig_Environment $environment)
    {
        
$this->engine->setEnvironment($environment);
    }
}
Онлайн: 1
Реклама