mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 07:33:50 +00:00
Add person menu entry for signature list
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<?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\MainBundle\Repository\Workflow;
|
||||
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
|
||||
interface EntityWorkflowSignatureACLAwareRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @return array<EntityWorkflowStepSignature>
|
||||
*/
|
||||
public function findByPersonAndPendingState(Person $person): array;
|
||||
}
|
@@ -18,9 +18,9 @@ use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
class EntityWorkflowStepRepository implements ObjectRepository
|
||||
readonly class EntityWorkflowStepRepository implements ObjectRepository
|
||||
{
|
||||
private readonly EntityRepository $repository;
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
|
@@ -0,0 +1,54 @@
|
||||
<?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\MainBundle\Repository\Workflow;
|
||||
|
||||
use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum;
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflowSignatureStateEnum;
|
||||
use Chill\MainBundle\Workflow\EntityWorkflowManager;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
class EntityWorkflowStepSignatureACLAwareRepository implements EntityWorkflowSignatureACLAwareRepositoryInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityWorkflowStepSignatureRepository $repository,
|
||||
private readonly EntityWorkflowManager $entityWorkflowManager,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function findByPersonAndPendingState(Person $person): array
|
||||
{
|
||||
$signatures = $this->repository->findByPerson($person);
|
||||
|
||||
$filteredSignatures = [];
|
||||
|
||||
foreach ($signatures as $signature) {
|
||||
if (EntityWorkflowSignatureStateEnum::SIGNED === $signature->getState() || EntityWorkflowSignatureStateEnum::CANCELED === $signature->getState() || EntityWorkflowSignatureStateEnum::REJECTED === $signature->getState()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$workflow = $signature->getStep()->getEntityWorkflow();
|
||||
|
||||
$storedObject = $this->entityWorkflowManager->getAssociatedStoredObject($workflow);
|
||||
|
||||
if (null === $storedObject) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->security->isGranted(StoredObjectRoleEnum::SEE->value, $storedObject)) {
|
||||
$filteredSignatures[] = $signature;
|
||||
}
|
||||
}
|
||||
|
||||
return $filteredSignatures;
|
||||
}
|
||||
}
|
@@ -12,43 +12,28 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Repository\Workflow;
|
||||
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @template-implements ObjectRepository<EntityWorkflowStepSignature>
|
||||
* @template-extends ServiceEntityRepository<EntityWorkflowStepSignature>
|
||||
*/
|
||||
class EntityWorkflowStepSignatureRepository implements ObjectRepository
|
||||
class EntityWorkflowStepSignatureRepository extends ServiceEntityRepository
|
||||
{
|
||||
private readonly \Doctrine\ORM\EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
$this->repository = $entityManager->getRepository(EntityWorkflowStepSignature::class);
|
||||
parent::__construct($registry, EntityWorkflowStepSignature::class);
|
||||
}
|
||||
|
||||
public function find($id): ?EntityWorkflowStepSignature
|
||||
public function findByPerson(Person $person): array
|
||||
{
|
||||
return $this->repository->find($id);
|
||||
}
|
||||
$qb = $this->createQueryBuilder('ewss');
|
||||
$qb->select('ewss');
|
||||
$qb->where($qb->expr()->eq('ewss.personSigner', ':person'));
|
||||
|
||||
public function findAll(): array
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
$qb->setParameter('person', $person);
|
||||
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
|
||||
{
|
||||
return $this->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria): ?EntityWorkflowStepSignature
|
||||
{
|
||||
return $this->findOneBy($criteria);
|
||||
}
|
||||
|
||||
public function getClassName(): string
|
||||
{
|
||||
return EntityWorkflowStepSignature::class;
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user