mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Add suggested persons and third parties methods
Introduced getSuggestedPersons and getSuggestedThirdParties methods across various WorkflowHandlers. These methods integrate with ProvidePersonsAssociated and ProvideThirdPartiesAssociated services to fetch related entities, enhancing the workflow handling capabilities.
This commit is contained in:
parent
4f18b1d2b2
commit
261bc88b5e
@ -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);
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -238,6 +238,16 @@ class WorkflowViewSendPublicControllerTest extends TestCase
|
||||
{
|
||||
return 'content';
|
||||
}
|
||||
|
||||
public function getSuggestedPersons(EntityWorkflow $entityWorkflow): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getSuggestedThirdParties(EntityWorkflow $entityWorkflow): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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<Person>
|
||||
*/
|
||||
public function getSuggestedPersons(EntityWorkflow $entityWorkflow): array;
|
||||
|
||||
/**
|
||||
* @return list<ThirdParty>
|
||||
*/
|
||||
public function getSuggestedThirdParties(EntityWorkflow $entityWorkflow): array;
|
||||
|
||||
public function getTemplate(EntityWorkflow $entityWorkflow, array $options = []): string;
|
||||
|
||||
public function getTemplateData(EntityWorkflow $entityWorkflow, array $options = []): array;
|
||||
|
@ -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<Person>
|
||||
*/
|
||||
public function getSuggestedPersons(EntityWorkflow $entityWorkflow): array
|
||||
{
|
||||
return $this->getHandler($entityWorkflow)->getSuggestedPersons($entityWorkflow);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<ThirdParty>
|
||||
*/
|
||||
public function getSuggestedThirdParties(EntityWorkflow $entityWorkflow): array
|
||||
{
|
||||
return $this->getHandler($entityWorkflow)->getSuggestedThirdParties($entityWorkflow);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user