mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-26 08:35:00 +00:00
Adjust logic for removing the hold on a workflow only by user who owns the hold and when a transition is applied on the workflow
This commit is contained in:
@@ -12,12 +12,14 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Repository\Workflow;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStep;
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepHold;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\ORM\NonUniqueResultException;
|
||||
use Doctrine\ORM\NoResultException;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\Workflow\Workflow;
|
||||
|
||||
/**
|
||||
* @template-extends ServiceEntityRepository<EntityWorkflowStepHold>
|
||||
@@ -58,6 +60,23 @@ class EntityWorkflowStepHoldRepository extends ServiceEntityRepository
|
||||
return $this->findBy(['step' => $step]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws NonUniqueResultException
|
||||
*/
|
||||
public function findByWorkflow(EntityWorkflow $workflow): ?EntityWorkflowStepHold
|
||||
{
|
||||
$qb = $this->getEntityManager()->createQueryBuilder();
|
||||
|
||||
$qb->select('h')
|
||||
->from(EntityWorkflowStepHold::class, 'h')
|
||||
->join('h.step', 's')
|
||||
->join('s.entityWorkflow', 'w')
|
||||
->where('w = :workflow')
|
||||
->setParameter('workflow', $workflow);
|
||||
|
||||
return $qb->getQuery()->getOneOrNullResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a single EntityWorkflowStepHold by step and user.
|
||||
*
|
||||
|
Reference in New Issue
Block a user