Handle cases when there are multiple EntityWorkflows associated with one entity

This commit is contained in:
2024-07-15 18:58:08 +02:00
parent 31f842471a
commit 9e92ede16f
9 changed files with 31 additions and 25 deletions

View File

@@ -13,7 +13,6 @@ namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;

View File

@@ -135,10 +135,10 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW
return false;
}
public function findByRelatedEntity(object $object): ?EntityWorkflow
public function findByRelatedEntity(object $object): array
{
if (!$object instanceof AccompanyingPeriodWorkEvaluationDocument) {
return null;
return [];
}
return $this->workflowRepository->findByRelatedEntity(AccompanyingPeriodWorkEvaluationDocument::class, $object->getId());

View File

@@ -21,13 +21,13 @@ use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvalu
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkEvaluationVoter;
use Symfony\Contracts\Translation\TranslatorInterface;
class AccompanyingPeriodWorkEvaluationWorkflowHandler implements EntityWorkflowHandlerInterface
readonly class AccompanyingPeriodWorkEvaluationWorkflowHandler implements EntityWorkflowHandlerInterface
{
public function __construct(
private readonly AccompanyingPeriodWorkEvaluationRepository $repository,
private readonly EntityWorkflowRepository $workflowRepository,
private readonly TranslatableStringHelperInterface $translatableStringHelper,
private readonly TranslatorInterface $translator
private AccompanyingPeriodWorkEvaluationRepository $repository,
private EntityWorkflowRepository $workflowRepository,
private TranslatableStringHelperInterface $translatableStringHelper,
private TranslatorInterface $translator
) {}
public function getDeletionRoles(): array
@@ -121,10 +121,10 @@ class AccompanyingPeriodWorkEvaluationWorkflowHandler implements EntityWorkflowH
return false;
}
public function findByRelatedEntity(object $object): ?EntityWorkflow
public function findByRelatedEntity(object $object): array
{
if (!$object instanceof AccompanyingPeriodWorkEvaluation) {
return null;
return [];
}
return $this->workflowRepository->findByRelatedEntity(AccompanyingPeriodWorkEvaluation::class, $object->getId());

View File

@@ -128,10 +128,10 @@ class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHandlerInte
return false;
}
public function findByRelatedEntity(object $object): ?EntityWorkflow
public function findByRelatedEntity(object $object): array
{
if (!$object instanceof AccompanyingPeriodWork) {
return null;
return [];
}
return $this->workflowRepository->findByRelatedEntity(AccompanyingPeriodWork::class, $object->getId());