mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 07:33:50 +00:00
Handle cases when there are multiple EntityWorkflows associated with one entity
This commit is contained in:
@@ -99,7 +99,10 @@ class EntityWorkflowRepository implements ObjectRepository
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
public function findByRelatedEntity($entityClass, $relatedEntityId): ?EntityWorkflow
|
||||
/**
|
||||
* @return list<EntityWorkflow>
|
||||
*/
|
||||
public function findByRelatedEntity($entityClass, $relatedEntityId): array
|
||||
{
|
||||
$qb = $this->repository->createQueryBuilder('w');
|
||||
|
||||
|
@@ -52,5 +52,8 @@ interface EntityWorkflowHandlerInterface
|
||||
|
||||
public function supportsFreeze(EntityWorkflow $entityWorkflow, array $options = []): bool;
|
||||
|
||||
public function findByRelatedEntity(object $object): ?EntityWorkflow;
|
||||
/**
|
||||
* @return list<EntityWorkflow>
|
||||
*/
|
||||
public function findByRelatedEntity(object $object): array;
|
||||
}
|
||||
|
@@ -38,12 +38,17 @@ class EntityWorkflowManager
|
||||
return $this->registry->all($entityWorkflow);
|
||||
}
|
||||
|
||||
public function findByRelatedEntity(object $object): ?EntityWorkflow
|
||||
/**
|
||||
* @return list<EntityWorkflow>
|
||||
*/
|
||||
public function findByRelatedEntity(object $object): array
|
||||
{
|
||||
foreach ($this->handlers as $handler) {
|
||||
return $handler->findByRelatedEntity($object);
|
||||
if ([] !== $workflows = $handler->findByRelatedEntity($object)) {
|
||||
return $workflows;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user