getRelatedEntity($entityWorkflow)?->getCourse(); $persons = []; if (null !== $course) { $persons = $course->getCurrentParticipations()->map(static fn (AccompanyingPeriodParticipation $participation) => $participation->getPerson())->toArray(); } return [ 'persons' => array_values($persons), ]; } public function getEntityTitle(EntityWorkflow $entityWorkflow, array $options = []): string { $doc = $this->getRelatedEntity($entityWorkflow); if (null === $doc) { return $this->translator->trans('workflow.Document deleted'); } return $this->translator->trans('workflow.Document (n°%doc%)', ['%doc%' => $entityWorkflow->getRelatedEntityId()]) .' - '.$doc->getTitle(); } public function getRelatedEntity(EntityWorkflow $entityWorkflow): ?AccompanyingCourseDocument { return $this->repository->find($entityWorkflow->getRelatedEntityId()); } /** * @param AccompanyingCourseDocument $object * * @return array[] */ public function getRelatedObjects(object $object): array { return [ ['entityClass' => AccompanyingCourseDocument::class, 'entityId' => $object->getId()], ]; } public function getRoleShow(EntityWorkflow $entityWorkflow): ?string { return null; } public function getSuggestedUsers(EntityWorkflow $entityWorkflow): array { $suggestedUsers = $entityWorkflow->getUsersInvolved(); $referrer = $this->getRelatedEntity($entityWorkflow)->getCourse()->getUser(); $suggestedUsers[spl_object_hash($referrer)] = $referrer; return $suggestedUsers; } public function getTemplate(EntityWorkflow $entityWorkflow, array $options = []): string { return '@ChillDocStore/AccompanyingCourseDocument/_workflow.html.twig'; } public function getTemplateData(EntityWorkflow $entityWorkflow, array $options = []): array { return [ 'entity_workflow' => $entityWorkflow, 'document' => $this->getRelatedEntity($entityWorkflow), ]; } public function isObjectSupported(object $object): bool { return $object instanceof AccompanyingCourseDocument; } public function supports(EntityWorkflow $entityWorkflow, array $options = []): bool { return AccompanyingCourseDocument::class === $entityWorkflow->getRelatedEntityClass(); } public function supportsFreeze(EntityWorkflow $entityWorkflow, array $options = []): bool { return false; } public function findByRelatedEntity(object $object): ?EntityWorkflow { if (!$object instanceof AccompanyingCourseDocument) { return null; } return $this->workflowRepository->findByRelatedEntity(AccompanyingCourseDocument::class, $object->getId()); } }