From 80b942db11fe93749a778fbcebcf80adcabfbb50 Mon Sep 17 00:00:00 2001 From: Andreas Schempp Date: Tue, 26 Nov 2024 15:36:34 +0100 Subject: [PATCH] Use config file instead of attribute or annotation --- config/routes.php | 12 ++++++++++++ src/ContaoManager/Plugin.php | 4 ++-- src/Controller/DownloadBulkyItemController.php | 6 ------ 3 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 config/routes.php diff --git a/config/routes.php b/config/routes.php new file mode 100644 index 0000000..cecf3d8 --- /dev/null +++ b/config/routes.php @@ -0,0 +1,12 @@ +add('nc_bulky_item_download', '/notifications/download/{voucher}') + ->controller(DownloadBulkyItemController::class) + ->requirements(['voucher' => BulkyItemStorage::VOUCHER_REGEX]) + ; +}; diff --git a/src/ContaoManager/Plugin.php b/src/ContaoManager/Plugin.php index 4fbfb10..14820a9 100644 --- a/src/ContaoManager/Plugin.php +++ b/src/ContaoManager/Plugin.php @@ -28,8 +28,8 @@ public function getBundles(ParserInterface $parser): array public function getRouteCollection(LoaderResolverInterface $resolver, KernelInterface $kernel) { return $resolver - ->resolve(DownloadBulkyItemController::class) - ->load(DownloadBulkyItemController::class) + ->resolve(__DIR__.'/../../config/routes.php') + ->load(__DIR__.'/../../config/routes.php') ; } } diff --git a/src/Controller/DownloadBulkyItemController.php b/src/Controller/DownloadBulkyItemController.php index e08ea28..3ec2f55 100644 --- a/src/Controller/DownloadBulkyItemController.php +++ b/src/Controller/DownloadBulkyItemController.php @@ -9,14 +9,8 @@ use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpFoundation\UriSigner; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Component\Routing\Annotation\Route; use Terminal42\NotificationCenterBundle\BulkyItem\BulkyItemStorage; -/** - * Do not use PHP attribute for compatibility with Contao 4.13/Symfony 5.4. - * - * @Route("/notifications/download/{voucher}", name="nc_bulky_item_download", requirements={"voucher"=BulkyItemStorage::VOUCHER_REGEX}) - */ class DownloadBulkyItemController { public function __construct(