mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 05:44:24 +00:00
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.
42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
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;
|
|
|
|
class StoredObjectStatusApiController
|
|
{
|
|
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(),
|
|
]
|
|
);
|
|
}
|
|
}
|