mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 23:23:51 +00:00
Handle cases when there are multiple EntityWorkflows associated with one entity
This commit is contained in:
@@ -11,7 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\DocStoreBundle\Service;
|
||||
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
||||
use Chill\MainBundle\Workflow\EntityWorkflowManager;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
@@ -21,13 +20,10 @@ class WorkflowDocumentService
|
||||
|
||||
public function notBlockedByWorkflow(object $entity): bool
|
||||
{
|
||||
/**
|
||||
* @var EntityWorkflow
|
||||
*/
|
||||
$workflow = $this->entityWorkflowManager->findByRelatedEntity($entity);
|
||||
$workflows = $this->entityWorkflowManager->findByRelatedEntity($entity);
|
||||
$currentUser = $this->security->getUser();
|
||||
|
||||
if (null != $workflow) {
|
||||
foreach ($workflows as $workflow) {
|
||||
if ($workflow->isFinal()) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -121,10 +121,10 @@ readonly class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkfl
|
||||
return false;
|
||||
}
|
||||
|
||||
public function findByRelatedEntity(object $object): ?EntityWorkflow
|
||||
public function findByRelatedEntity(object $object): array
|
||||
{
|
||||
if (!$object instanceof AccompanyingCourseDocument) {
|
||||
return null;
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->workflowRepository->findByRelatedEntity(AccompanyingCourseDocument::class, $object->getId());
|
||||
|
Reference in New Issue
Block a user