src/Controller/Sync/Routing/CollectionAction.php line 28

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 App\Controller\Sync\Routing;
  11. use App\Service\Sync\Routing\Routing;
  12. use Drosalys\Bundle\ApiBundle\Pagination\Attributes\Paginable;
  13. use Drosalys\Bundle\ApiBundle\Routing\Attributes\Get;
  14. use Drosalys\Bundle\ApiBundle\Serializer\Attributes\Serializable;
  15. use Nellapp\Bundle\SDKBundle\Sync\Routing\RouteCollection;
  16. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  17. use Symfony\Component\HttpFoundation\Request;
  18. use Symfony\Component\Security\Core\Security;
  19. /**
  20.  * Class CollectionAction
  21.  *
  22.  * @author Benjamin Georgeault
  23.  */
  24. class CollectionAction
  25. {
  26.     public function __construct(
  27.         private Routing $routing,
  28.         private Security $security,
  29.     ) {}
  30.     /**
  31.      * Get Routes collections for core and apps.
  32.      */
  33.     #[Get('/routing/routes')]
  34.     #[Serializable]
  35.     #[Paginable(RouteCollection::class, limit50maxLimit50)]
  36.     #[IsGranted('ROLE_USER')]
  37.     public function __invoke(Request $request): array
  38.     {
  39.         return $this->routing->getCollections($this->security->getUser(), cachefalse);
  40.     }
  41. }