diff --git a/src/Bundle/ChillDocStoreBundle/Tests/Workflow/AccompanyingCourseDocumentWorkflowHandlerTest.php b/src/Bundle/ChillDocStoreBundle/Tests/Workflow/AccompanyingCourseDocumentWorkflowHandlerTest.php index e40b240f4..cf8bc9c7c 100644 --- a/src/Bundle/ChillDocStoreBundle/Tests/Workflow/AccompanyingCourseDocumentWorkflowHandlerTest.php +++ b/src/Bundle/ChillDocStoreBundle/Tests/Workflow/AccompanyingCourseDocumentWorkflowHandlerTest.php @@ -13,10 +13,14 @@ namespace Chill\DocStoreBundle\Tests\Workflow; use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument; use Chill\DocStoreBundle\Repository\AccompanyingCourseDocumentRepository; +use Chill\DocStoreBundle\Workflow\AccompanyingCourseDocumentWorkflowHandler; +use Chill\DocStoreBundle\Workflow\WorkflowWithPublicViewDocumentHelper; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\Workflow\EntityWorkflow; use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository; use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Service\AccompanyingPeriod\ProvidePersonsAssociated; +use Chill\PersonBundle\Service\AccompanyingPeriod\ProvideThirdPartiesAssociated; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Contracts\Translation\TranslatorInterface; @@ -45,6 +49,8 @@ class AccompanyingCourseDocumentWorkflowHandlerTest extends TestCase $this->prophesize(EntityWorkflowRepository::class)->reveal(), $this->buildRepository($document, 1), new WorkflowWithPublicViewDocumentHelper($this->prophesize(Environment::class)->reveal()), + $this->prophesize(ProvideThirdPartiesAssociated::class)->reveal(), + $this->prophesize(ProvidePersonsAssociated::class)->reveal(), ); $users = $handler->getSuggestedUsers($entityWorkflow); @@ -68,6 +74,8 @@ class AccompanyingCourseDocumentWorkflowHandlerTest extends TestCase $this->prophesize(EntityWorkflowRepository::class)->reveal(), $this->buildRepository($document, 1), new WorkflowWithPublicViewDocumentHelper($this->prophesize(Environment::class)->reveal()), + $this->prophesize(ProvideThirdPartiesAssociated::class)->reveal(), + $this->prophesize(ProvidePersonsAssociated::class)->reveal(), ); $users = $handler->getSuggestedUsers($entityWorkflow); diff --git a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php index b98e5d4a9..193568286 100644 --- a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php +++ b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php @@ -22,6 +22,8 @@ use Chill\MainBundle\Workflow\EntityWorkflowWithPublicViewInterface; use Chill\MainBundle\Workflow\EntityWorkflowWithStoredObjectHandlerInterface; use Chill\MainBundle\Workflow\Templating\EntityWorkflowViewMetadataDTO; use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; +use Chill\PersonBundle\Service\AccompanyingPeriod\ProvideThirdPartiesAssociated; +use Chill\PersonBundle\Service\AccompanyingPeriod\ProvidePersonsAssociated; use Symfony\Contracts\Translation\TranslatorInterface; /** @@ -34,6 +36,8 @@ final readonly class AccompanyingCourseDocumentWorkflowHandler implements Entity private EntityWorkflowRepository $workflowRepository, private AccompanyingCourseDocumentRepository $repository, private WorkflowWithPublicViewDocumentHelper $publicViewDocumentHelper, + private ProvideThirdPartiesAssociated $thirdPartiesAssociated, + private ProvidePersonsAssociated $providePersonsAssociated, ) {} public function getDeletionRoles(): array @@ -161,4 +165,26 @@ final readonly class AccompanyingCourseDocumentWorkflowHandler implements Entity { return $this->publicViewDocumentHelper->render($entityWorkflowSend, $metadata, $this); } + + public function getSuggestedPersons(EntityWorkflow $entityWorkflow): array + { + $related = $this->getRelatedEntity($entityWorkflow); + + if (null === $related) { + return []; + } + + return $this->providePersonsAssociated->getPersonsAssociated($related->getCourse()); + } + + public function getSuggestedThirdParties(EntityWorkflow $entityWorkflow): array + { + $related = $this->getRelatedEntity($entityWorkflow); + + if (null === $related) { + return []; + } + + return $this->thirdPartiesAssociated->getThirdPartiesAssociated($related->getCourse()); + } } diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/WorkflowViewSendPublicControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/WorkflowViewSendPublicControllerTest.php index 02bee8f4f..d5a4d6561 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/WorkflowViewSendPublicControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/WorkflowViewSendPublicControllerTest.php @@ -238,6 +238,16 @@ class WorkflowViewSendPublicControllerTest extends TestCase { return 'content'; } + + public function getSuggestedPersons(EntityWorkflow $entityWorkflow): array + { + return []; + } + + public function getSuggestedThirdParties(EntityWorkflow $entityWorkflow): array + { + return []; + } }; } diff --git a/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowHandlerInterface.php b/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowHandlerInterface.php index c0d6469f6..0cc03084e 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowHandlerInterface.php +++ b/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowHandlerInterface.php @@ -13,6 +13,8 @@ namespace Chill\MainBundle\Workflow; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\Workflow\EntityWorkflow; +use Chill\PersonBundle\Entity\Person; +use Chill\ThirdPartyBundle\Entity\ThirdParty; /** * @template T of object @@ -48,6 +50,16 @@ interface EntityWorkflowHandlerInterface */ public function getSuggestedUsers(EntityWorkflow $entityWorkflow): array; + /** + * @return list + */ + public function getSuggestedPersons(EntityWorkflow $entityWorkflow): array; + + /** + * @return list + */ + public function getSuggestedThirdParties(EntityWorkflow $entityWorkflow): array; + public function getTemplate(EntityWorkflow $entityWorkflow, array $options = []): string; public function getTemplateData(EntityWorkflow $entityWorkflow, array $options = []): array; diff --git a/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowManager.php b/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowManager.php index 16cfd66b7..474370127 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowManager.php +++ b/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowManager.php @@ -18,6 +18,8 @@ use Chill\MainBundle\Entity\Workflow\EntityWorkflowSend; use Chill\MainBundle\Workflow\Exception\HandlerNotFoundException; use Chill\MainBundle\Workflow\Exception\HandlerWithPublicViewNotFoundException; use Chill\MainBundle\Workflow\Templating\EntityWorkflowViewMetadataDTO; +use Chill\PersonBundle\Entity\Person; +use Chill\ThirdPartyBundle\Entity\ThirdParty; use Symfony\Component\Workflow\Registry; /** @@ -120,4 +122,20 @@ class EntityWorkflowManager ) ); } + + /** + * @return list + */ + public function getSuggestedPersons(EntityWorkflow $entityWorkflow): array + { + return $this->getHandler($entityWorkflow)->getSuggestedPersons($entityWorkflow); + } + + /** + * @return list + */ + public function getSuggestedThirdParties(EntityWorkflow $entityWorkflow): array + { + return $this->getHandler($entityWorkflow)->getSuggestedThirdParties($entityWorkflow); + } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandlerTest.php b/src/Bundle/ChillPersonBundle/Tests/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandlerTest.php index 2e7076a4d..df701d906 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandlerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandlerTest.php @@ -19,6 +19,8 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocumentRepository; +use Chill\PersonBundle\Service\AccompanyingPeriodWork\ProvidePersonsAssociated; +use Chill\PersonBundle\Service\AccompanyingPeriodWork\ProvideThirdPartiesAssociated; use Chill\PersonBundle\Workflow\AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; @@ -59,6 +61,8 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandlerTest extends TestCa $translatableStringHelperProphecy->reveal(), $translatorProphecy->reveal(), new WorkflowWithPublicViewDocumentHelper($twig->reveal()), + $this->prophesize(ProvideThirdPartiesAssociated::class)->reveal(), + $this->prophesize(ProvidePersonsAssociated::class)->reveal(), ); $entityWorkflow->setRelatedEntityId(1); diff --git a/src/Bundle/ChillPersonBundle/Tests/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandlerTest.php b/src/Bundle/ChillPersonBundle/Tests/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandlerTest.php index 1f62e5bb3..bcd1e8c8a 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandlerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandlerTest.php @@ -17,6 +17,9 @@ use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationRepository; +use Chill\PersonBundle\Service\AccompanyingPeriodWork\ProvidePersonsAssociated; +use Chill\PersonBundle\Service\AccompanyingPeriodWork\ProvideThirdPartiesAssociated; +use Chill\PersonBundle\Workflow\AccompanyingPeriodWorkEvaluationWorkflowHandler; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Contracts\Translation\TranslatorInterface; @@ -53,6 +56,8 @@ class AccompanyingPeriodWorkEvaluationWorkflowHandlerTest extends TestCase $workflowRepositoryProphecy->reveal(), $translatableStringHelperProphecy->reveal(), $translatorProphecy->reveal(), + $this->prophesize(ProvideThirdPartiesAssociated::class)->reveal(), + $this->prophesize(ProvidePersonsAssociated::class)->reveal(), ); $users = $handler->getSuggestedUsers($entityWorkflow); diff --git a/src/Bundle/ChillPersonBundle/Tests/Workflow/AccompanyingPeriodWorkWorkflowHandlerTest.php b/src/Bundle/ChillPersonBundle/Tests/Workflow/AccompanyingPeriodWorkWorkflowHandlerTest.php index 1d3702871..5fcaf8eb4 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Workflow/AccompanyingPeriodWorkWorkflowHandlerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Workflow/AccompanyingPeriodWorkWorkflowHandlerTest.php @@ -17,6 +17,9 @@ use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository; +use Chill\PersonBundle\Service\AccompanyingPeriodWork\ProvidePersonsAssociated; +use Chill\PersonBundle\Service\AccompanyingPeriodWork\ProvideThirdPartiesAssociated; +use Chill\PersonBundle\Workflow\AccompanyingPeriodWorkWorkflowHandler; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Contracts\Translation\TranslatorInterface; @@ -52,6 +55,8 @@ class AccompanyingPeriodWorkWorkflowHandlerTest extends TestCase $workflowRepositoryProphecy->reveal(), $translatableStringHelperProphecy->reveal(), $translatorProphecy->reveal(), + $this->prophesize(ProvideThirdPartiesAssociated::class)->reveal(), + $this->prophesize(ProvidePersonsAssociated::class)->reveal(), ); $users = $handler->getSuggestedUsers($entityWorkflow); diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php index 1168d8f35..780b81c1d 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php @@ -23,6 +23,8 @@ use Chill\MainBundle\Workflow\Templating\EntityWorkflowViewMetadataDTO; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocumentRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkEvaluationDocumentVoter; +use Chill\PersonBundle\Service\AccompanyingPeriodWork\ProvidePersonsAssociated; +use Chill\PersonBundle\Service\AccompanyingPeriodWork\ProvideThirdPartiesAssociated; use Symfony\Contracts\Translation\TranslatorInterface; /** @@ -36,6 +38,8 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly TranslatorInterface $translator, private readonly WorkflowWithPublicViewDocumentHelper $publicViewDocumentHelper, + private readonly ProvideThirdPartiesAssociated $provideThirdPartiesAssociated, + private readonly ProvidePersonsAssociated $providePersonsAssociated, ) {} public function getDeletionRoles(): array @@ -179,4 +183,26 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW { return $this->publicViewDocumentHelper->render($entityWorkflowSend, $metadata, $this); } + + public function getSuggestedPersons(EntityWorkflow $entityWorkflow): array + { + $related = $this->getRelatedEntity($entityWorkflow); + + if (null === $related) { + return []; + } + + return $this->providePersonsAssociated->getPersonsAssociated($related->getAccompanyingPeriodWorkEvaluation()->getAccompanyingPeriodWork()); + } + + public function getSuggestedThirdParties(EntityWorkflow $entityWorkflow): array + { + $related = $this->getRelatedEntity($entityWorkflow); + + if (null === $related) { + return []; + } + + return $this->provideThirdPartiesAssociated->getThirdPartiesAssociated($related->getAccompanyingPeriodWorkEvaluation()->getAccompanyingPeriodWork()); + } } diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php index 302bbb0be..3e72e65bd 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php @@ -19,6 +19,8 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluatio use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkEvaluationVoter; +use Chill\PersonBundle\Service\AccompanyingPeriodWork\ProvidePersonsAssociated; +use Chill\PersonBundle\Service\AccompanyingPeriodWork\ProvideThirdPartiesAssociated; use Symfony\Contracts\Translation\TranslatorInterface; /** @@ -31,6 +33,8 @@ readonly class AccompanyingPeriodWorkEvaluationWorkflowHandler implements Entity private EntityWorkflowRepository $workflowRepository, private TranslatableStringHelperInterface $translatableStringHelper, private TranslatorInterface $translator, + private ProvideThirdPartiesAssociated $provideThirdPartiesAssociated, + private ProvidePersonsAssociated $providePersonsAssociated, ) {} public function getDeletionRoles(): array @@ -147,4 +151,26 @@ readonly class AccompanyingPeriodWorkEvaluationWorkflowHandler implements Entity return $this->workflowRepository->findByRelatedEntity(AccompanyingPeriodWorkEvaluation::class, $object->getId()); } + + public function getSuggestedPersons(EntityWorkflow $entityWorkflow): array + { + $related = $this->getRelatedEntity($entityWorkflow); + + if (null === $related) { + return []; + } + + return $this->providePersonsAssociated->getPersonsAssociated($related->getAccompanyingPeriodWork()); + } + + public function getSuggestedThirdParties(EntityWorkflow $entityWorkflow): array + { + $related = $this->getRelatedEntity($entityWorkflow); + + if (null === $related) { + return []; + } + + return $this->provideThirdPartiesAssociated->getThirdPartiesAssociated($related->getAccompanyingPeriodWork()); + } } diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php index 8a7b5ef48..58d3c9875 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php @@ -20,6 +20,8 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluatio use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkVoter; +use Chill\PersonBundle\Service\AccompanyingPeriodWork\ProvidePersonsAssociated; +use Chill\PersonBundle\Service\AccompanyingPeriodWork\ProvideThirdPartiesAssociated; use Symfony\Contracts\Translation\TranslatorInterface; /** @@ -32,6 +34,8 @@ readonly class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHa private EntityWorkflowRepository $workflowRepository, private TranslatableStringHelperInterface $translatableStringHelper, private TranslatorInterface $translator, + private ProvideThirdPartiesAssociated $thirdPartiesAssociated, + private ProvidePersonsAssociated $providePersonsAssociated, ) {} public function getDeletionRoles(): array @@ -151,4 +155,26 @@ readonly class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHa return $this->workflowRepository->findByRelatedEntity(AccompanyingPeriodWork::class, $object->getId()); } + + public function getSuggestedPersons(EntityWorkflow $entityWorkflow): array + { + $related = $this->getRelatedEntity($entityWorkflow); + + if (null === $related) { + return []; + } + + return $this->providePersonsAssociated->getPersonsAssociated($related); + } + + public function getSuggestedThirdParties(EntityWorkflow $entityWorkflow): array + { + $related = $this->getRelatedEntity($entityWorkflow); + + if (null === $related) { + return []; + } + + return $this->thirdPartiesAssociated->getThirdPartiesAssociated($related); + } }