fix merge

This commit is contained in:
Nicolas Grekas 2017-06-02 11:00:03 +02:00
parent 59751226e2
commit 8d609d9bba
8 changed files with 15 additions and 11 deletions

View File

@ -28,7 +28,7 @@ CHANGELOG
// ...
$rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'), $twig);
// require Twig 1.30+
$twig->addRuntimeLoader(new \Twig_FactoryRuntimeLoader(array(
$twig->addRuntimeLoader(new \Twig\RuntimeLoader\FactoryRuntimeLoader(array(
TwigRenderer::class => function () use ($rendererEngine, $csrfTokenManager) {
return new TwigRenderer($rendererEngine, $csrfTokenManager);
},

View File

@ -38,7 +38,7 @@ class FormExtension extends AbstractExtension implements InitRuntimeInterface
public function __construct($renderer = null)
{
if ($renderer instanceof TwigRendererInterface) {
@trigger_error(sprintf('Passing a Twig Form Renderer to the "%s" constructor is deprecated since version 3.2 and won\'t be possible in 4.0. Pass the Twig_Environment to the TwigRendererEngine constructor instead.', static::class), E_USER_DEPRECATED);
@trigger_error(sprintf('Passing a Twig Form Renderer to the "%s" constructor is deprecated since version 3.2 and won\'t be possible in 4.0. Pass the Twig\Environment to the TwigRendererEngine constructor instead.', static::class), E_USER_DEPRECATED);
} elseif (null !== $renderer && !(is_array($renderer) && isset($renderer[0], $renderer[1]) && $renderer[0] instanceof ContainerInterface)) {
throw new \InvalidArgumentException(sprintf('Passing any arguments the constructor of %s is reserved for internal use.', __CLASS__));
}

View File

@ -13,13 +13,15 @@ namespace Symfony\Bridge\Twig\Extension;
use Symfony\Component\Workflow\Registry;
use Symfony\Component\Workflow\Transition;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
/**
* WorkflowExtension.
*
* @author Grégoire Pineau <lyrixx@lyrixx.info>
*/
class WorkflowExtension extends \Twig_Extension
class WorkflowExtension extends AbstractExtension
{
private $workflowRegistry;
@ -31,8 +33,8 @@ class WorkflowExtension extends \Twig_Extension
public function getFunctions()
{
return array(
new \Twig_SimpleFunction('workflow_can', array($this, 'canTransition')),
new \Twig_SimpleFunction('workflow_transitions', array($this, 'getEnabledTransitions')),
new TwigFunction('workflow_can', array($this, 'canTransition')),
new TwigFunction('workflow_transitions', array($this, 'getEnabledTransitions')),
);
}

View File

@ -31,7 +31,7 @@ class TwigRendererEngine extends AbstractRendererEngine implements TwigRendererE
*/
private $template;
public function __construct(array $defaultThemes = array(), \Twig_Environment $environment = null)
public function __construct(array $defaultThemes = array(), Environment $environment = null)
{
if (null === $environment) {
@trigger_error(sprintf('Not passing a Twig Environment as the second argument for "%s" constructor is deprecated since version 3.2 and won\'t be possible in 4.0.', static::class), E_USER_DEPRECATED);

View File

@ -123,7 +123,7 @@ class DumpExtensionTest extends TestCase
'</pre><script>Sfdump("%s")</script>'
);
$extension = new DumpExtension(new VarCloner(), $dumper);
$twig = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array(
$twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), array(
'debug' => true,
'cache' => false,
'optimizations' => 0,

View File

@ -81,7 +81,7 @@ class HttpKernelExtensionTest extends TestCase
$twig = new Environment($loader, array('debug' => true, 'cache' => false));
$twig->addExtension(new HttpKernelExtension());
$loader = $this->getMockBuilder('Twig\Loader\RuntimeLoaderInterface')->getMock();
$loader = $this->getMockBuilder('Twig\RuntimeLoader\RuntimeLoaderInterface')->getMock();
$loader->expects($this->any())->method('load')->will($this->returnValueMap(array(
array('Symfony\Bridge\Twig\Extension\HttpKernelRuntime', new HttpKernelRuntime($renderer)),
)));

View File

@ -12,12 +12,13 @@
namespace Symfony\Bridge\Twig\Tests\Extension;
use Symfony\Bridge\Twig\Form\TwigRenderer;
use Twig\Environment;
trait RuntimeLoaderProvider
{
protected function registerTwigRuntimeLoader(\Twig_Environment $environment, TwigRenderer $renderer)
protected function registerTwigRuntimeLoader(Environment $environment, TwigRenderer $renderer)
{
$loader = $this->getMockBuilder('Twig_RuntimeLoaderInterface')->getMock();
$loader = $this->getMockBuilder('Twig\RuntimeLoader\RuntimeLoaderInterface')->getMock();
$loader->expects($this->any())->method('load')->will($this->returnValueMap(array(
array('Symfony\Bridge\Twig\Form\TwigRenderer', $renderer),
)));

View File

@ -13,13 +13,14 @@ namespace Symfony\Bundle\TwigBundle;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Twig\RuntimeLoader\RuntimeLoaderInterface;
/**
* Loads Twig extension runtimes via the service container.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class ContainerAwareRuntimeLoader implements \Twig_RuntimeLoaderInterface
class ContainerAwareRuntimeLoader implements RuntimeLoaderInterface
{
private $container;
private $mapping;