From e93fdca2d32b4ff3b791e88dbea777e9ce6de4f6 Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Sat, 5 Aug 2023 16:43:36 +0100 Subject: [PATCH] Use Twig instead of templating --- app/config/config.yml | 11 +++-- .../Controller/ExceptionController.php | 40 ------------------- .../TwigBundle}/Exception/error.html.twig | 0 3 files changed, 5 insertions(+), 46 deletions(-) delete mode 100644 src/Wallabag/CoreBundle/Controller/ExceptionController.php rename {src/Wallabag/CoreBundle/Resources/views => templates/bundles/TwigBundle}/Exception/error.html.twig (100%) diff --git a/app/config/config.yml b/app/config/config.yml index 62c1a500c..b31b29e0d 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -23,8 +23,6 @@ framework: csrf_protection: ~ validation: enable_annotations: true - templating: - engines: ['twig'] default_locale: "%locale%" trusted_hosts: ~ session: @@ -43,7 +41,6 @@ twig: strict_variables: "%kernel.debug%" form_themes: - "@LexikFormFilter/Form/form_div_layout.html.twig" - exception_controller: Wallabag\CoreBundle\Controller\ExceptionController:showAction globals: registration_enabled: '%fosuser_registration%' @@ -87,8 +84,13 @@ doctrine_migrations: executed_at_column_name: 'executed_at' fos_rest: + zone: + - { path: ^/api } + - { path: ^/annotations } param_fetcher_listener: true body_listener: true + exception: + serializer_error_renderer: true view: mime_types: csv: @@ -117,9 +119,6 @@ fos_rest: - { path: "^/api/entries/([0-9]+)/export.(.*)", priorities: ['epub', 'mobi', 'pdf', 'txt', 'csv'], fallback_format: json, prefer_extension: false } - { path: "^/api", priorities: ['json', 'xml'], fallback_format: json, prefer_extension: false } - { path: "^/annotations", priorities: ['json', 'xml'], fallback_format: json, prefer_extension: false } - # for an unknown reason, EACH REQUEST goes to FOS\RestBundle\EventListener\FormatListener - # so we need to add custom rule for custom api export but also for all other routes of the application... - - { path: '^/', priorities: ['text/html', '*/*'], fallback_format: html, prefer_extension: false } nelmio_api_doc: areas: diff --git a/src/Wallabag/CoreBundle/Controller/ExceptionController.php b/src/Wallabag/CoreBundle/Controller/ExceptionController.php deleted file mode 100644 index ffff3c85f..000000000 --- a/src/Wallabag/CoreBundle/Controller/ExceptionController.php +++ /dev/null @@ -1,40 +0,0 @@ -templateExists($template)) { - return $template; - } - } - - // try to find a template for the given format - $template = sprintf('@Twig/Exception/%s.%s.twig', $name, $format); - if ($this->templateExists($template)) { - return $template; - } - - // default to a generic HTML exception - $request->setRequestFormat('html'); - - return sprintf('@Twig/Exception/%s.html.twig', $showException ? 'exception_full' : $name); - } -} diff --git a/src/Wallabag/CoreBundle/Resources/views/Exception/error.html.twig b/templates/bundles/TwigBundle/Exception/error.html.twig similarity index 100% rename from src/Wallabag/CoreBundle/Resources/views/Exception/error.html.twig rename to templates/bundles/TwigBundle/Exception/error.html.twig