diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php index d6a58798c1369..678d573586f3a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php @@ -36,13 +36,6 @@ public function registerContainerConfiguration(LoaderInterface $loader) $loader->load(__DIR__.\DIRECTORY_SEPARATOR.'config.yml'); } - public function setAnnotatedClassCache(array $annotatedClasses) - { - $annotatedClasses = array_diff($annotatedClasses, ['Symfony\Bundle\WebProfilerBundle\Controller\ExceptionController', 'Symfony\Bundle\TwigBundle\Controller\ExceptionController', 'Symfony\Bundle\TwigBundle\Controller\PreviewErrorController']); - - parent::setAnnotatedClassCache($annotatedClasses); - } - protected function build(ContainerBuilder $container) { $container->register('logger', NullLogger::class); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/BundlePaths/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/BundlePaths/config.yml index 3e1e53738cf93..94994ba60c798 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/BundlePaths/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/BundlePaths/config.yml @@ -8,4 +8,3 @@ framework: twig: strict_variables: '%kernel.debug%' - exception_controller: null # to be removed in 5.0 diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/config.yml index ceeea37a1001b..16fc81dd268d4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/config.yml @@ -7,4 +7,3 @@ framework: twig: strict_variables: '%kernel.debug%' - exception_controller: null # to be removed in 5.0 diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/twig.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/twig.yml index f578e4b510378..493989866a278 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/twig.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/twig.yml @@ -2,4 +2,3 @@ twig: debug: '%kernel.debug%' strict_variables: '%kernel.debug%' - exception_controller: null # to be removed in 5.0 diff --git a/src/Symfony/Bundle/TwigBundle/CHANGELOG.md b/src/Symfony/Bundle/TwigBundle/CHANGELOG.md index 33c2b12854c25..007d725009a20 100644 --- a/src/Symfony/Bundle/TwigBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/TwigBundle/CHANGELOG.md @@ -8,8 +8,8 @@ CHANGELOG * removed support to load templates from the legacy directories `src/Resources/views/` and `src/Resources//views/` * removed `TwigEngine` class, use `Twig\Environment` instead * removed `FilesystemLoader` and `NativeFilesystemLoader`, use Twig notation for templates instead - * updated default value for the `twig.exception_controller` option to `null` - * removed `ExceptionController` class and all built-in error templates in favor of the new error renderer mechanism + * removed `twig.exception_controller` configuration option, use `framework.error_controller` option instead + * removed `ExceptionController`, `PreviewErrorController` and all built-in error templates in favor of the new error renderer mechanism 4.4.0 ----- diff --git a/src/Symfony/Bundle/TwigBundle/Controller/PreviewErrorController.php b/src/Symfony/Bundle/TwigBundle/Controller/PreviewErrorController.php deleted file mode 100644 index 3c5e028317286..0000000000000 --- a/src/Symfony/Bundle/TwigBundle/Controller/PreviewErrorController.php +++ /dev/null @@ -1,60 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\Controller; - -use Symfony\Component\ErrorRenderer\Exception\FlattenException; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use the "%s" instead.', PreviewErrorController::class, \Symfony\Component\HttpKernel\Controller\ErrorController::class), E_USER_DEPRECATED); - -/** - * PreviewErrorController can be used to test error pages. - * - * It will create a test exception and forward it to another controller. - * - * @author Matthias Pigulla - * - * @deprecated since Symfony 4.4, use the Symfony\Component\HttpKernel\Controller\ErrorController instead. - */ -class PreviewErrorController -{ - protected $kernel; - protected $controller; - - public function __construct(HttpKernelInterface $kernel, $controller) - { - $this->kernel = $kernel; - $this->controller = $controller; - } - - public function previewErrorPageAction(Request $request, int $code) - { - $exception = FlattenException::createFromThrowable(new \Exception('Something has intentionally gone wrong.'), $code); - - /* - * This Request mimics the parameters set by - * \Symfony\Component\HttpKernel\EventListener\ExceptionListener::duplicateRequest, with - * the additional "showException" flag. - */ - - $subRequest = $request->duplicate(null, null, [ - '_controller' => $this->controller, - 'exception' => $exception, - 'logger' => null, - 'format' => $request->getRequestFormat(), - 'showException' => false, - ]); - - return $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST); - } -} diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php deleted file mode 100644 index 738f7b5dac12c..0000000000000 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\DependencyInjection\Compiler; - -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; - -/** - * Registers the Twig exception listener if required dependencies do exist. - * - * @author Fabien Potencier - * - * @internal - */ -class ExceptionListenerPass implements CompilerPassInterface -{ - public function process(ContainerBuilder $container) - { - if (false === $container->hasDefinition('twig')) { - return; - } - - // to be removed in 5.0 - // register the exception listener only if it's currently used, else use the provided by FrameworkBundle - if (null === $container->getParameter('twig.exception_listener.controller') && $container->hasDefinition('exception_listener')) { - $container->removeDefinition('twig.exception_listener'); - } else { - $container->removeDefinition('exception_listener'); - - if ($container->hasParameter('templating.engines')) { - $engines = $container->getParameter('templating.engines'); - if (!\in_array('twig', $engines, true)) { - $container->removeDefinition('twig.exception_listener'); - } - } - } - } -} diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php index 3e8ee1a30906f..ca3e8ef2d1394 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php @@ -32,14 +32,6 @@ public function getConfigTreeBuilder() $treeBuilder = new TreeBuilder('twig'); $rootNode = $treeBuilder->getRootNode(); - $rootNode - ->children() - ->scalarNode('exception_controller') - ->defaultNull() - ->end() - ->end() - ; - $this->addFormThemesSection($rootNode); $this->addGlobalsSection($rootNode); $this->addTwigOptions($rootNode); diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php index b411b75d2a32d..2ef6d7d199204 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -70,8 +70,6 @@ public function load(array $configs, ContainerBuilder $container) $config = $this->processConfiguration($configuration, $configs); - $container->setParameter('twig.exception_listener.controller', $config['exception_controller']); - $container->setParameter('twig.form.resources', $config['form_themes']); $container->setParameter('twig.default_path', $config['default_path']); $defaultTwigPath = $container->getParameterBag()->resolveValue($config['default_path']); diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/routing/errors.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/routing/errors.xml deleted file mode 100644 index f01b7761bf9bc..0000000000000 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/routing/errors.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - twig.controller.preview_error::previewErrorPageAction - html - \d+ - - diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/schema/twig-1.0.xsd b/src/Symfony/Bundle/TwigBundle/Resources/config/schema/twig-1.0.xsd index 3e491f7029833..429c91db67b74 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/schema/twig-1.0.xsd +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/schema/twig-1.0.xsd @@ -25,7 +25,6 @@ - diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml index a54e9a067fb61..2bdf92d7567f6 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml @@ -117,27 +117,6 @@ - - - - %twig.exception_listener.controller% - - %kernel.debug% - The "%service_id%" service is deprecated since Symfony 4.4. - - - - - %kernel.debug% - The "%service_id%" service is deprecated since Symfony 4.4. - - - - - %twig.exception_listener.controller% - The "%service_id%" service is deprecated since Symfony 4.4. - - diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php deleted file mode 100644 index 0178276ee5d89..0000000000000 --- a/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\Tests\Controller; - -use Symfony\Bundle\TwigBundle\Controller\PreviewErrorController; -use Symfony\Bundle\TwigBundle\Tests\TestCase; -use Symfony\Component\ErrorRenderer\Exception\FlattenException; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -/** - * @group legacy - */ -class PreviewErrorControllerTest extends TestCase -{ - public function testForwardRequestToConfiguredController() - { - $request = Request::create('whatever'); - $response = new Response(''); - $code = 123; - $logicalControllerName = 'foo:bar:baz'; - - $kernel = $this->getMockBuilder('\Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $kernel - ->expects($this->once()) - ->method('handle') - ->with( - $this->callback(function (Request $request) use ($logicalControllerName, $code) { - $this->assertEquals($logicalControllerName, $request->attributes->get('_controller')); - - $exception = $request->attributes->get('exception'); - $this->assertInstanceOf(FlattenException::class, $exception); - $this->assertEquals($code, $exception->getStatusCode()); - $this->assertFalse($request->attributes->get('showException')); - - return true; - }), - $this->equalTo(HttpKernelInterface::SUB_REQUEST) - ) - ->willReturn($response); - - $controller = new PreviewErrorController($kernel, $logicalControllerName); - - $this->assertSame($response, $controller->previewErrorPageAction($request, $code)); - } -} diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php index 18d0ba50f90f2..8dd2be40960b1 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php @@ -17,7 +17,6 @@ 'charset' => 'ISO-8859-1', 'debug' => true, 'strict_variables' => true, - 'exception_controller' => null, // to be removed in 5.0 'default_path' => '%kernel.project_dir%/Fixtures/templates', 'paths' => [ 'path1', diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.xml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.xml index f95f052104f37..17bcf0acd4490 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.xml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.xml @@ -6,7 +6,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/twig https://symfony.com/schema/dic/twig/twig-1.0.xsd"> - + namespaced_path3 diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml index 665230134766e..8ece3b80b794d 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml @@ -6,7 +6,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/twig https://symfony.com/schema/dic/twig/twig-1.0.xsd"> - + MyBundle::form.html.twig @@qux diff --git a/src/Symfony/Bundle/TwigBundle/TwigBundle.php b/src/Symfony/Bundle/TwigBundle/TwigBundle.php index bd766c15219e7..483e5ae846737 100644 --- a/src/Symfony/Bundle/TwigBundle/TwigBundle.php +++ b/src/Symfony/Bundle/TwigBundle/TwigBundle.php @@ -11,7 +11,6 @@ namespace Symfony\Bundle\TwigBundle; -use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\ExceptionListenerPass; use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\ExtensionPass; use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\RuntimeLoaderPass; use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\TwigEnvironmentPass; @@ -35,7 +34,6 @@ public function build(ContainerBuilder $container) $container->addCompilerPass(new ExtensionPass()); $container->addCompilerPass(new TwigEnvironmentPass()); $container->addCompilerPass(new TwigLoaderPass()); - $container->addCompilerPass(new ExceptionListenerPass()); $container->addCompilerPass(new RuntimeLoaderPass(), PassConfig::TYPE_BEFORE_REMOVING); }