bootstrap generic doc manager and associated services

This commit is contained in:
2023-05-23 22:12:18 +02:00
parent 977299192f
commit afcd6e0605
10 changed files with 585 additions and 0 deletions

View File

@@ -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);
}
}