mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-11-11 06:38:26 +00:00
Add explicit controller definition requirement for APIs
Updated API creation to require an explicit controller definition. This change has been reflected in the ChillMainExtension and ChillPersonExtension files. Also, it has introduced a new exception, the InvalidCrudConfiguration, which will be thrown when a new API or CRUD is created without this explicit controller definition.
This commit is contained in:
@@ -11,31 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\DocStoreBundle\Controller;
|
||||
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
|
||||
class StoredObjectApiController
|
||||
{
|
||||
public function __construct(private readonly Security $security) {}
|
||||
|
||||
#[Route(path: '/api/1.0/doc-store/stored-object/{uuid}/is-ready')]
|
||||
public function isDocumentReady(StoredObject $storedObject): Response
|
||||
{
|
||||
if (!$this->security->isGranted('ROLE_USER')) {
|
||||
throw new AccessDeniedHttpException();
|
||||
}
|
||||
|
||||
return new JsonResponse(
|
||||
[
|
||||
'id' => $storedObject->getId(),
|
||||
'filename' => $storedObject->getFilename(),
|
||||
'status' => $storedObject->getStatus(),
|
||||
'type' => $storedObject->getType(),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
class StoredObjectApiController extends ApiController {}
|
||||
|
||||
Reference in New Issue
Block a user