repository = $em->getRepository(AccompanyingCourseDocument::class); $this->translator = $translator; } public function getEntityData(EntityWorkflow $entityWorkflow, array $options = []): array { $course = $this->getRelatedEntity($entityWorkflow) ->getCourse(); $persons = []; if (null !== $course) { $persons = $course->getCurrentParticipations()->map(static function (AccompanyingPeriodParticipation $participation) { return $participation->getPerson(); })->toArray(); } return [ 'persons' => array_values($persons), ]; } public function getEntityTitle(EntityWorkflow $entityWorkflow, array $options = []): string { $doc = $this->getRelatedEntity($entityWorkflow); 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()); } public function getRoleShow(EntityWorkflow $entityWorkflow): ?string { return null; } 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 supports(EntityWorkflow $entityWorkflow, array $options = []): bool { return $entityWorkflow->getRelatedEntityClass() === AccompanyingCourseDocument::class; } public function supportsFreeze(EntityWorkflow $entityWorkflow, array $options = []): bool { return true; } }