mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
bootstrap generic doc manager and associated services
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?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\GenericDoc\Manager;
|
||||
use Chill\DocStoreBundle\Security\Authorization\AccompanyingCourseDocumentVoter;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
final readonly class GenericDocForAccompanyingPeriodController
|
||||
{
|
||||
public function __construct(
|
||||
private Security $security,
|
||||
private Manager $manager
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccompanyingPeriod $accompanyingPeriod
|
||||
* @return Response
|
||||
* @throws \Doctrine\DBAL\Exception
|
||||
*
|
||||
* @Route("/{_locale}/doc-store/generic-doc/by-period/{id}/index", name="chill_docstore_generic-doc_by-period_index")
|
||||
*/
|
||||
public function list(AccompanyingPeriod $accompanyingPeriod): Response
|
||||
{
|
||||
if (!$this->security->isGranted(AccompanyingCourseDocumentVoter::SEE, $accompanyingPeriod)) {
|
||||
throw new AccessDeniedHttpException("not allowed to see the documents for accompanying period");
|
||||
}
|
||||
|
||||
$nb = $this->manager->countDocForAccompanyingPeriod($accompanyingPeriod);
|
||||
|
||||
return new Response($nb);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user