diff --git a/composer.json b/composer.json index 42be8e2b4ee41..94b5d85cc0393 100644 --- a/composer.json +++ b/composer.json @@ -46,6 +46,7 @@ "symfony/dom-crawler": "self.version", "symfony/dotenv": "self.version", "symfony/event-dispatcher": "self.version", + "symfony/error-page-bundle": "self.version", "symfony/expression-language": "self.version", "symfony/filesystem": "self.version", "symfony/finder": "self.version", diff --git a/src/Symfony/Bundle/ErrorPageBundle/.gitignore b/src/Symfony/Bundle/ErrorPageBundle/.gitignore new file mode 100644 index 0000000000000..c49a5d8df5c65 --- /dev/null +++ b/src/Symfony/Bundle/ErrorPageBundle/.gitignore @@ -0,0 +1,3 @@ +vendor/ +composer.lock +phpunit.xml diff --git a/src/Symfony/Bundle/ErrorPageBundle/CHANGELOG.md b/src/Symfony/Bundle/ErrorPageBundle/CHANGELOG.md new file mode 100644 index 0000000000000..ad2db49e7c2c0 --- /dev/null +++ b/src/Symfony/Bundle/ErrorPageBundle/CHANGELOG.md @@ -0,0 +1,7 @@ +CHANGELOG +========= + +4.0.0 +----- + + * Separated from TwigBundle diff --git a/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php b/src/Symfony/Bundle/ErrorPageBundle/Controller/ExceptionController.php similarity index 92% rename from src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php rename to src/Symfony/Bundle/ErrorPageBundle/Controller/ExceptionController.php index f9e86c4daa21d..aec7f52043c3c 100644 --- a/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php +++ b/src/Symfony/Bundle/ErrorPageBundle/Controller/ExceptionController.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Bundle\TwigBundle\Controller; +namespace Symfony\Bundle\ErrorPageBundle\Controller; use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; @@ -105,14 +105,14 @@ protected function findTemplate(Request $request, $format, $code, $showException // For error pages, try to find a template for the specific HTTP status code and format if (!$showException) { - $template = sprintf('@Twig/Exception/%s%s.%s.twig', $name, $code, $format); + $template = sprintf('@ErrorPage/Exception/%s%s.%s.twig', $name, $code, $format); if ($this->templateExists($template)) { return $template; } } // try to find a template for the given format - $template = sprintf('@Twig/Exception/%s.%s.twig', $name, $format); + $template = sprintf('@ErrorPage/Exception/%s.%s.twig', $name, $format); if ($this->templateExists($template)) { return $template; } @@ -120,7 +120,7 @@ protected function findTemplate(Request $request, $format, $code, $showException // default to a generic HTML exception $request->setRequestFormat('html'); - return sprintf('@Twig/Exception/%s.html.twig', $showException ? 'exception_full' : $name); + return sprintf('@ErrorPage/Exception/%s.html.twig', $showException ? 'exception_full' : $name); } // to be removed when the minimum required version of Twig is >= 3.0 diff --git a/src/Symfony/Bundle/TwigBundle/Controller/PreviewErrorController.php b/src/Symfony/Bundle/ErrorPageBundle/Controller/PreviewErrorController.php similarity index 96% rename from src/Symfony/Bundle/TwigBundle/Controller/PreviewErrorController.php rename to src/Symfony/Bundle/ErrorPageBundle/Controller/PreviewErrorController.php index a907ef0abe5b2..07b4731ca9173 100644 --- a/src/Symfony/Bundle/TwigBundle/Controller/PreviewErrorController.php +++ b/src/Symfony/Bundle/ErrorPageBundle/Controller/PreviewErrorController.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Bundle\TwigBundle\Controller; +namespace Symfony\Bundle\ErrorPageBundle\Controller; use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\HttpKernel\HttpKernelInterface; diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php b/src/Symfony/Bundle/ErrorPageBundle/DependencyInjection/Compiler/ExceptionListenerPass.php similarity index 78% rename from src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php rename to src/Symfony/Bundle/ErrorPageBundle/DependencyInjection/Compiler/ExceptionListenerPass.php index b7ebb2a406512..fb9e743bf6cd3 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php +++ b/src/Symfony/Bundle/ErrorPageBundle/DependencyInjection/Compiler/ExceptionListenerPass.php @@ -9,13 +9,13 @@ * file that was distributed with this source code. */ -namespace Symfony\Bundle\TwigBundle\DependencyInjection\Compiler; +namespace Symfony\Bundle\ErrorPageBundle\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; /** - * Registers the Twig exception listener if Twig is registered as a templating engine. + * Registers the exception listener if Twig is registered as a templating engine. * * @author Fabien Potencier */ @@ -29,11 +29,11 @@ public function process(ContainerBuilder $container) // register the exception controller only if Twig is enabled and required dependencies do exist if (!class_exists('Symfony\Component\Debug\Exception\FlattenException') || !interface_exists('Symfony\Component\EventDispatcher\EventSubscriberInterface')) { - $container->removeDefinition('twig.exception_listener'); + $container->removeDefinition('error_page.exception_listener'); } elseif ($container->hasParameter('templating.engines')) { $engines = $container->getParameter('templating.engines'); if (!in_array('twig', $engines)) { - $container->removeDefinition('twig.exception_listener'); + $container->removeDefinition('error_page.exception_listener'); } } } diff --git a/src/Symfony/Bundle/ErrorPageBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/ErrorPageBundle/DependencyInjection/Configuration.php new file mode 100644 index 0000000000000..8a01000aa9666 --- /dev/null +++ b/src/Symfony/Bundle/ErrorPageBundle/DependencyInjection/Configuration.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\ErrorPageBundle\DependencyInjection; + +use Symfony\Component\Config\Definition\Builder\TreeBuilder; +use Symfony\Component\Config\Definition\ConfigurationInterface; + +/** + * ErrorPageExtension configuration structure. + * + * @author Jeremy Mikola + */ +class Configuration implements ConfigurationInterface +{ + /** + * Generates the configuration tree builder. + * + * @return TreeBuilder The tree builder + */ + public function getConfigTreeBuilder() + { + $treeBuilder = new TreeBuilder(); + $rootNode = $treeBuilder->root('error_page'); + + $rootNode + ->children() + ->scalarNode('exception_controller')->defaultValue('error_page.controller.exception:showAction')->end() + ->end() + ; + + return $treeBuilder; + } +} diff --git a/src/Symfony/Bundle/ErrorPageBundle/DependencyInjection/ErrorPageExtension.php b/src/Symfony/Bundle/ErrorPageBundle/DependencyInjection/ErrorPageExtension.php new file mode 100644 index 0000000000000..0dcdaf6487347 --- /dev/null +++ b/src/Symfony/Bundle/ErrorPageBundle/DependencyInjection/ErrorPageExtension.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\ErrorPageBundle\DependencyInjection; + +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; + +/** + * ErrorPageExtension. + * + * @author Fabien Potencier + * @author Jeremy Mikola + */ +class ErrorPageExtension extends Extension +{ + /** + * @param array $configs + * @param ContainerBuilder $container + */ + public function load(array $configs, ContainerBuilder $container) + { + $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('error_page.xml'); + + $configuration = $this->getConfiguration($configs, $container); + + $config = $this->processConfiguration($configuration, $configs); + + $container->setParameter('error_page.exception_listener.controller', $config['exception_controller']); + } +} diff --git a/src/Symfony/Bundle/ErrorPageBundle/ErrorPageBundle.php b/src/Symfony/Bundle/ErrorPageBundle/ErrorPageBundle.php new file mode 100644 index 0000000000000..d9545bace245d --- /dev/null +++ b/src/Symfony/Bundle/ErrorPageBundle/ErrorPageBundle.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\ErrorPageBundle; + +use Symfony\Component\HttpKernel\Bundle\Bundle; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Bundle\ErrorPageBundle\DependencyInjection\Compiler\ExceptionListenerPass; + +/** + * ErrorPageBundle + * + * @author Fabien Potencier + */ +class ErrorPageBundle extends Bundle +{ + public function build(ContainerBuilder $container) + { + parent::build($container); + + $container->addCompilerPass(new ExceptionListenerPass()); + } +} diff --git a/src/Symfony/Bundle/ErrorPageBundle/LICENSE b/src/Symfony/Bundle/ErrorPageBundle/LICENSE new file mode 100644 index 0000000000000..17d16a13367dd --- /dev/null +++ b/src/Symfony/Bundle/ErrorPageBundle/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2004-2017 Fabien Potencier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/Symfony/Bundle/ErrorPageBundle/README.md b/src/Symfony/Bundle/ErrorPageBundle/README.md new file mode 100644 index 0000000000000..c07d1f2d612be --- /dev/null +++ b/src/Symfony/Bundle/ErrorPageBundle/README.md @@ -0,0 +1,10 @@ +ErrorPageBundle +========== + +Resources +--------- + + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Bundle/ErrorPageBundle/Resources/config/error_page.xml b/src/Symfony/Bundle/ErrorPageBundle/Resources/config/error_page.xml new file mode 100644 index 0000000000000..f7ade983958bb --- /dev/null +++ b/src/Symfony/Bundle/ErrorPageBundle/Resources/config/error_page.xml @@ -0,0 +1,25 @@ + + + + + + + + + %error_page.exception_listener.controller% + + + + + + %kernel.debug% + + + + + %error_page.exception_listener.controller% + + + diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/routing/errors.xml b/src/Symfony/Bundle/ErrorPageBundle/Resources/config/routing/errors.xml similarity index 100% rename from src/Symfony/Bundle/TwigBundle/Resources/config/routing/errors.xml rename to src/Symfony/Bundle/ErrorPageBundle/Resources/config/routing/errors.xml diff --git a/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/error.atom.twig b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/error.atom.twig new file mode 100644 index 0000000000000..f085d92cde76b --- /dev/null +++ b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/error.atom.twig @@ -0,0 +1 @@ +{{ include('@ErrorPage/Exception/error.xml.twig') }} diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.css.twig b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/error.css.twig similarity index 100% rename from src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.css.twig rename to src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/error.css.twig diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.html.twig b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/error.html.twig similarity index 100% rename from src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.html.twig rename to src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/error.html.twig diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.js.twig b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/error.js.twig similarity index 100% rename from src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.js.twig rename to src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/error.js.twig diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.json.twig b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/error.json.twig similarity index 100% rename from src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.json.twig rename to src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/error.json.twig diff --git a/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/error.rdf.twig b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/error.rdf.twig new file mode 100644 index 0000000000000..f085d92cde76b --- /dev/null +++ b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/error.rdf.twig @@ -0,0 +1 @@ +{{ include('@ErrorPage/Exception/error.xml.twig') }} diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.txt.twig b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/error.txt.twig similarity index 100% rename from src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.txt.twig rename to src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/error.txt.twig diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.xml.twig b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/error.xml.twig similarity index 100% rename from src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.xml.twig rename to src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/error.xml.twig diff --git a/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.atom.twig b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.atom.twig new file mode 100644 index 0000000000000..69a7653b6c08d --- /dev/null +++ b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.atom.twig @@ -0,0 +1 @@ +{{ include('@ErrorPage/Exception/exception.xml.twig', { exception: exception }) }} diff --git a/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.css.twig b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.css.twig new file mode 100644 index 0000000000000..03a34b98cf227 --- /dev/null +++ b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.css.twig @@ -0,0 +1,3 @@ +/* +{{ include('@ErrorPage/Exception/exception.txt.twig', { exception: exception }) }} +*/ diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.html.twig b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.html.twig similarity index 82% rename from src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.html.twig rename to src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.html.twig index 4b35e4fad77db..6295df871d533 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.html.twig +++ b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.html.twig @@ -4,7 +4,7 @@

{% for previousException in exception.allPrevious|reverse %} {{ previousException.class|abbr_class }} - {{ include('@Twig/images/chevron-right.svg') }} + {{ include('@ErrorPage/images/chevron-right.svg') }} {% endfor %} {{ exception.class|abbr_class }}

@@ -20,7 +20,7 @@
- {{ include('@Twig/images/symfony-ghost.svg') }} + {{ include('@ErrorPage/images/symfony-ghost.svg') }}
@@ -48,7 +48,7 @@
{% for i, e in exception_as_array %} - {{ include('@Twig/Exception/traces.html.twig', { exception: e, index: loop.index, expand: i in _exceptions_with_user_code or (_exceptions_with_user_code is empty and loop.first) }, with_context = false) }} + {{ include('@ErrorPage/Exception/traces.html.twig', { exception: e, index: loop.index, expand: i in _exceptions_with_user_code or (_exceptions_with_user_code is empty and loop.first) }, with_context = false) }} {% endfor %}
@@ -61,7 +61,7 @@
{% if logger %} - {{ include('@Twig/Exception/logs.html.twig', { logs: logger.logs }, with_context = false) }} + {{ include('@ErrorPage/Exception/logs.html.twig', { logs: logger.logs }, with_context = false) }} {% else %}

No log messages

@@ -81,7 +81,7 @@
{% for e in exception_as_array %} - {{ include('@Twig/Exception/traces_text.html.twig', { exception: e, index: loop.index, num_exceptions: loop.length }, with_context = false) }} + {{ include('@ErrorPage/Exception/traces_text.html.twig', { exception: e, index: loop.index, num_exceptions: loop.length }, with_context = false) }} {% endfor %}
diff --git a/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.js.twig b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.js.twig new file mode 100644 index 0000000000000..03a34b98cf227 --- /dev/null +++ b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.js.twig @@ -0,0 +1,3 @@ +/* +{{ include('@ErrorPage/Exception/exception.txt.twig', { exception: exception }) }} +*/ diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.json.twig b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.json.twig similarity index 100% rename from src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.json.twig rename to src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.json.twig diff --git a/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.rdf.twig b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.rdf.twig new file mode 100644 index 0000000000000..69a7653b6c08d --- /dev/null +++ b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.rdf.twig @@ -0,0 +1 @@ +{{ include('@ErrorPage/Exception/exception.xml.twig', { exception: exception }) }} diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.txt.twig b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.txt.twig similarity index 68% rename from src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.txt.twig rename to src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.txt.twig index cb17fb149f9ab..c38a318be3a78 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.txt.twig +++ b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.txt.twig @@ -2,6 +2,6 @@ [message] {{ exception.message }} {% for i, e in exception.toarray %} [{{ i + 1 }}] {{ e.class }}: {{ e.message }} -{{ include('@Twig/Exception/traces.txt.twig', { exception: e }, with_context = false) }} +{{ include('@ErrorPage/Exception/traces.txt.twig', { exception: e }, with_context = false) }} {% endfor %} diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.xml.twig b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.xml.twig similarity index 72% rename from src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.xml.twig rename to src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.xml.twig index 36c9449b6c505..42aed58c71bba 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.xml.twig +++ b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception.xml.twig @@ -3,7 +3,7 @@ {% for e in exception.toarray %} -{{ include('@Twig/Exception/traces.xml.twig', { exception: e }, with_context = false) }} +{{ include('@ErrorPage/Exception/traces.xml.twig', { exception: e }, with_context = false) }} {% endfor %} diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception_full.html.twig b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception_full.html.twig similarity index 97% rename from src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception_full.html.twig rename to src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception_full.html.twig index e4f220896ecda..1f8300a787045 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception_full.html.twig +++ b/src/Symfony/Bundle/ErrorPageBundle/Resources/views/Exception/exception_full.html.twig @@ -1,4 +1,4 @@ -{% extends '@Twig/layout.html.twig' %} +{% extends '@ErrorPage/layout.html.twig' %} {% block head %}