feature #22783 [TwigBridge] remove deprecated features (xabbuh)
This PR was merged into the 4.0-dev branch.
Discussion
----------
[TwigBridge] remove deprecated features
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| BC breaks? | yes
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
Commits
-------
aae494c
[TwigBridge] remove deprecated features
This commit is contained in:
commit
aac9273765
@ -12,12 +12,8 @@
|
||||
namespace Symfony\Bridge\Twig\Extension;
|
||||
|
||||
use Symfony\Bridge\Twig\TokenParser\FormThemeTokenParser;
|
||||
use Symfony\Bridge\Twig\Form\TwigRendererInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
|
||||
use Twig\Environment;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\Extension\InitRuntimeInterface;
|
||||
use Twig\TwigFilter;
|
||||
use Twig\TwigFunction;
|
||||
use Twig\TwigTest;
|
||||
@ -28,37 +24,8 @@ use Twig\TwigTest;
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class FormExtension extends AbstractExtension implements InitRuntimeInterface
|
||||
class FormExtension extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
* @deprecated since version 3.2, to be removed in 4.0 alongside with magic methods below
|
||||
*/
|
||||
private $renderer;
|
||||
|
||||
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);
|
||||
} 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__));
|
||||
}
|
||||
$this->renderer = $renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* To be removed in 4.0
|
||||
*/
|
||||
public function initRuntime(Environment $environment)
|
||||
{
|
||||
if ($this->renderer instanceof TwigRendererInterface) {
|
||||
$this->renderer->setEnvironment($environment);
|
||||
} elseif (null !== $this->renderer) {
|
||||
$this->renderer[2] = $environment;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -108,62 +75,6 @@ class FormExtension extends AbstractExtension implements InitRuntimeInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
if ('renderer' === $name) {
|
||||
@trigger_error(sprintf('Using the "%s::$renderer" property is deprecated since version 3.2 as it will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
|
||||
|
||||
if (is_array($this->renderer)) {
|
||||
$renderer = $this->renderer[0]->get($this->renderer[1]);
|
||||
if (isset($this->renderer[2])) {
|
||||
$renderer->setEnvironment($this->renderer[2]);
|
||||
}
|
||||
$this->renderer = $renderer;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
{
|
||||
if ('renderer' === $name) {
|
||||
@trigger_error(sprintf('Using the "%s::$renderer" property is deprecated since version 3.2 as it will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
$this->$name = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function __isset($name)
|
||||
{
|
||||
if ('renderer' === $name) {
|
||||
@trigger_error(sprintf('Using the "%s::$renderer" property is deprecated since version 3.2 as it will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
return isset($this->$name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function __unset($name)
|
||||
{
|
||||
if ('renderer' === $name) {
|
||||
@trigger_error(sprintf('Using the "%s::$renderer" property is deprecated since version 3.2 as it will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
unset($this->$name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -43,15 +43,7 @@ class YamlExtension extends AbstractExtension
|
||||
}
|
||||
|
||||
if (defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT')) {
|
||||
if (is_bool($dumpObjects)) {
|
||||
@trigger_error('Passing a boolean flag to toggle object support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::DUMP_OBJECT flag instead.', E_USER_DEPRECATED);
|
||||
|
||||
$flags = $dumpObjects ? Yaml::DUMP_OBJECT : 0;
|
||||
} else {
|
||||
$flags = $dumpObjects;
|
||||
}
|
||||
|
||||
return $dumper->dump($input, $inline, 0, $flags);
|
||||
return $dumper->dump($input, $inline, 0, $dumpObjects);
|
||||
}
|
||||
|
||||
return $dumper->dump($input, $inline, 0, false, $dumpObjects);
|
||||
|
@ -1,49 +0,0 @@
|
||||
<?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\Bridge\Twig\Form;
|
||||
|
||||
@trigger_error(sprintf('The %s class is deprecated since version 3.4 and will be removed in 4.0. Use %s instead.', TwigRenderer::class, FormRenderer::class), E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Form\FormRenderer;
|
||||
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||
use Twig\Environment;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @deprecated since version 3.4, to be removed in 4.0. Use Symfony\Component\Form\FormRenderer instead.
|
||||
*/
|
||||
class TwigRenderer extends FormRenderer implements TwigRendererInterface
|
||||
{
|
||||
public function __construct(TwigRendererEngineInterface $engine, CsrfTokenManagerInterface $csrfTokenManager = null)
|
||||
{
|
||||
parent::__construct($engine, $csrfTokenManager);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the engine used by this renderer.
|
||||
*
|
||||
* @return TwigRendererEngineInterface The renderer engine
|
||||
*/
|
||||
public function getEngine()
|
||||
{
|
||||
return parent::getEngine();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setEnvironment(Environment $environment)
|
||||
{
|
||||
$this->getEngine()->setEnvironment($environment);
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ use Twig\Template;
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class TwigRendererEngine extends AbstractRendererEngine implements TwigRendererEngineInterface
|
||||
class TwigRendererEngine extends AbstractRendererEngine
|
||||
{
|
||||
/**
|
||||
* @var Environment
|
||||
@ -31,30 +31,12 @@ class TwigRendererEngine extends AbstractRendererEngine implements TwigRendererE
|
||||
*/
|
||||
private $template;
|
||||
|
||||
public function __construct(array $defaultThemes = array(), Environment $environment = null)
|
||||
public function __construct(array $defaultThemes, Environment $environment)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
parent::__construct($defaultThemes);
|
||||
$this->environment = $environment;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @deprecated since version 3.3, to be removed in 4.0
|
||||
*/
|
||||
public function setEnvironment(Environment $environment)
|
||||
{
|
||||
if ($this->environment) {
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since version 3.3 and will be removed in 4.0. Pass the Twig Environment as second argument of the constructor instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
$this->environment = $environment;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -1,28 +0,0 @@
|
||||
<?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\Bridge\Twig\Form;
|
||||
|
||||
use Symfony\Component\Form\FormRendererEngineInterface;
|
||||
use Twig\Environment;
|
||||
|
||||
// BC/FC with namespaced Twig
|
||||
class_exists('Twig\Environment');
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @deprecated since version 3.2, to be removed in 4.0.
|
||||
*/
|
||||
interface TwigRendererEngineInterface extends FormRendererEngineInterface
|
||||
{
|
||||
public function setEnvironment(Environment $environment);
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
<?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\Bridge\Twig\Form;
|
||||
|
||||
use Symfony\Component\Form\FormRendererInterface;
|
||||
use Twig\Environment;
|
||||
|
||||
// BC/FC with namespaced Twig
|
||||
class_exists('Twig\Environment');
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @deprecated since version 3.2, to be removed in 4.0.
|
||||
*/
|
||||
interface TwigRendererInterface extends FormRendererInterface
|
||||
{
|
||||
public function setEnvironment(Environment $environment);
|
||||
}
|
@ -11,10 +11,8 @@
|
||||
|
||||
namespace Symfony\Bridge\Twig\Node;
|
||||
|
||||
use Symfony\Bridge\Twig\Form\TwigRenderer;
|
||||
use Symfony\Component\Form\FormRenderer;
|
||||
use Twig\Compiler;
|
||||
use Twig\Error\RuntimeError;
|
||||
use Twig\Node\Node;
|
||||
|
||||
/**
|
||||
@ -29,17 +27,10 @@ class FormThemeNode extends Node
|
||||
|
||||
public function compile(Compiler $compiler)
|
||||
{
|
||||
try {
|
||||
$compiler->getEnvironment()->getRuntime(FormRenderer::class);
|
||||
$renderer = FormRenderer::class;
|
||||
} catch (RuntimeError $e) {
|
||||
$renderer = TwigRenderer::class;
|
||||
}
|
||||
|
||||
$compiler
|
||||
->addDebugInfo($this)
|
||||
->write('$this->env->getRuntime(')
|
||||
->string($renderer)
|
||||
->string(FormRenderer::class)
|
||||
->raw(')->setTheme(')
|
||||
->subcompile($this->getNode('form'))
|
||||
->raw(', ')
|
||||
|
Reference in New Issue
Block a user