mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 21:13:57 +00:00
Merge branch '331-manage-attachments-to-workflow' into 'master'
Add attachments to workflow Closes #331 See merge request Chill-Projet/chill-bundles!764
This commit is contained in:
@@ -11,7 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\DocStoreBundle\Controller;
|
||||
|
||||
use Chill\DocStoreBundle\GenericDoc\Manager;
|
||||
use Chill\DocStoreBundle\GenericDoc\ManagerInterface;
|
||||
use Chill\DocStoreBundle\Security\Authorization\AccompanyingCourseDocumentVoter;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactory;
|
||||
@@ -25,7 +25,7 @@ final readonly class GenericDocForAccompanyingPeriodController
|
||||
{
|
||||
public function __construct(
|
||||
private FilterOrderHelperFactory $filterOrderHelperFactory,
|
||||
private Manager $manager,
|
||||
private ManagerInterface $manager,
|
||||
private PaginatorFactory $paginator,
|
||||
private Security $security,
|
||||
private \Twig\Environment $twig,
|
||||
@@ -68,6 +68,9 @@ final readonly class GenericDocForAccompanyingPeriodController
|
||||
);
|
||||
$paginator = $this->paginator->create($nb);
|
||||
|
||||
// restrict the number of items for performance reasons
|
||||
$paginator->setItemsPerPage(20);
|
||||
|
||||
$documents = $this->manager->findDocForAccompanyingPeriod(
|
||||
$accompanyingPeriod,
|
||||
$paginator->getCurrentPageFirstItemNumber(),
|
||||
|
@@ -0,0 +1,57 @@
|
||||
<?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\ManagerInterface;
|
||||
use Chill\DocStoreBundle\Security\Authorization\AccompanyingCourseDocumentVoter;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactoryInterface;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
|
||||
/**
|
||||
* Provide the list of GenericDoc for an accompanying period.
|
||||
*/
|
||||
final readonly class GenericDocForAccompanyingPeriodListApiController
|
||||
{
|
||||
public function __construct(
|
||||
private ManagerInterface $manager,
|
||||
private Security $security,
|
||||
private PaginatorFactoryInterface $paginator,
|
||||
private SerializerInterface $serializer,
|
||||
) {}
|
||||
|
||||
#[Route('/api/1.0/doc-store/generic-doc/by-period/{id}/index', methods: ['GET'])]
|
||||
public function __invoke(AccompanyingPeriod $accompanyingPeriod): JsonResponse
|
||||
{
|
||||
if (!$this->security->isGranted(AccompanyingCourseDocumentVoter::SEE, $accompanyingPeriod)) {
|
||||
throw new AccessDeniedHttpException('not allowed to see the documents for accompanying period');
|
||||
}
|
||||
|
||||
$nb = $this->manager->countDocForAccompanyingPeriod($accompanyingPeriod);
|
||||
$paginator = $this->paginator->create($nb);
|
||||
|
||||
$docs = $this->manager->findDocForAccompanyingPeriod($accompanyingPeriod, $paginator->getCurrentPageFirstItemNumber(), $paginator->getItemsPerPage());
|
||||
|
||||
$collection = new Collection($docs, $paginator);
|
||||
|
||||
return new JsonResponse(
|
||||
$this->serializer->serialize($collection, 'json', [AbstractNormalizer::GROUPS => ['read']]),
|
||||
json: true,
|
||||
);
|
||||
}
|
||||
}
|
@@ -11,7 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\DocStoreBundle\Controller;
|
||||
|
||||
use Chill\DocStoreBundle\GenericDoc\Manager;
|
||||
use Chill\DocStoreBundle\GenericDoc\ManagerInterface;
|
||||
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactory;
|
||||
@@ -25,7 +25,7 @@ final readonly class GenericDocForPerson
|
||||
{
|
||||
public function __construct(
|
||||
private FilterOrderHelperFactory $filterOrderHelperFactory,
|
||||
private Manager $manager,
|
||||
private ManagerInterface $manager,
|
||||
private PaginatorFactory $paginator,
|
||||
private Security $security,
|
||||
private \Twig\Environment $twig,
|
||||
|
Reference in New Issue
Block a user