Skip to content

Commit

Permalink
Use config file instead of attribute or annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Nov 26, 2024
1 parent 7b2595f commit 80b942d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
12 changes: 12 additions & 0 deletions config/routes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Terminal42\NotificationCenterBundle\BulkyItem\BulkyItemStorage;
use Terminal42\NotificationCenterBundle\Controller\DownloadBulkyItemController;

return function (RoutingConfigurator $routes): void {
$routes->add('nc_bulky_item_download', '/notifications/download/{voucher}')
->controller(DownloadBulkyItemController::class)
->requirements(['voucher' => BulkyItemStorage::VOUCHER_REGEX])
;
};
4 changes: 2 additions & 2 deletions src/ContaoManager/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
;
}
}
6 changes: 0 additions & 6 deletions src/Controller/DownloadBulkyItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 80b942d

Please sign in to comment.