vendor/nellapp/sdk-bundle/src/Sync/Routing/Controller/Sync/CollectionAction.php line 27

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the nellapp-core package.
  4.  *
  5.  * (c) Benjamin Georgeault
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Nellapp\Bundle\SDKBundle\Sync\Routing\Controller\Sync;
  11. use Drosalys\Bundle\ApiBundle\Routing\Attributes\Get;
  12. use Drosalys\Bundle\ApiBundle\Serializer\Attributes\Serializable;
  13. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  14. use Symfony\Component\Routing\Generator\UrlGenerator;
  15. use Symfony\Component\Routing\Route;
  16. use Symfony\Component\Routing\RouteCollection;
  17. use Symfony\Component\Routing\RouterInterface;
  18. /**
  19.  * Class CollectionAction
  20.  *
  21.  * @author Benjamin Georgeault
  22.  */
  23. class CollectionAction
  24. {
  25.     public function __construct(
  26.         private RouterInterface $router,
  27.     ) {}
  28.     #[Get('/routes'name'nellapp_sdk_routing_routes')]
  29.     #[Serializable('Sync')]
  30.     #[IsGranted('ROLE_USER')]
  31.     public function __invoke(): array
  32.     {
  33.         return array_filter($this->router->getRouteCollection()->all(), function (string $routeName) {
  34.             return !preg_match('/^(_)|(nellapp_sdk)/'$routeName);
  35.         }, ARRAY_FILTER_USE_KEY);
  36.     }
  37. }