<?php
/*
* This file is part of the nellapp-core package.
*
* (c) Benjamin Georgeault
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Controller\Sync\Routing;
use App\Service\Sync\Routing\Routing;
use Drosalys\Bundle\ApiBundle\Pagination\Attributes\Paginable;
use Drosalys\Bundle\ApiBundle\Routing\Attributes\Get;
use Drosalys\Bundle\ApiBundle\Serializer\Attributes\Serializable;
use Nellapp\Bundle\SDKBundle\Sync\Routing\RouteCollection;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Security;
/**
* Class CollectionAction
*
* @author Benjamin Georgeault
*/
class CollectionAction
{
public function __construct(
private Routing $routing,
private Security $security,
) {}
/**
* Get Routes collections for core and apps.
*/
#[Get('/routing/routes')]
#[Serializable]
#[Paginable(RouteCollection::class, limit: 50, maxLimit: 50)]
#[IsGranted('ROLE_USER')]
public function __invoke(Request $request): array
{
return $this->routing->getCollections($this->security->getUser(), cache: false);
}
}