mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
88 lines
2.8 KiB
PHP
88 lines
2.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Chill\PersonBundle\Workflow;
|
|
|
|
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
|
use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface;
|
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
|
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
|
|
|
class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHandlerInterface
|
|
{
|
|
private AccompanyingPeriodWorkRepository $repository;
|
|
|
|
private TranslatorInterface $translator;
|
|
|
|
public function __construct(AccompanyingPeriodWorkRepository $repository, TranslatorInterface $translator)
|
|
{
|
|
$this->repository = $repository;
|
|
$this->translator = $translator;
|
|
}
|
|
|
|
public function getEntityData(EntityWorkflow $entityWorkflow, array $options = []): array
|
|
{
|
|
return [
|
|
'persons' => $this->getRelatedEntity($entityWorkflow)
|
|
->getPersons(),
|
|
];
|
|
}
|
|
|
|
public function getEntityTitle(EntityWorkflow $entityWorkflow, array $options = []): string
|
|
{
|
|
return $this->translator->trans('workflow.Work (n°%w%)', ['%w%' => $entityWorkflow->getRelatedEntityId()]);
|
|
}
|
|
|
|
public function getRelatedEntity(EntityWorkflow $entityWorkflow): ?AccompanyingPeriodWork
|
|
{
|
|
return $this->repository->find($entityWorkflow->getRelatedEntityId());
|
|
}
|
|
|
|
public function getRoleShow(EntityWorkflow $entityWorkflow): ?string
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public function getTemplate(EntityWorkflow $entityWorkflow, array $options = []): string
|
|
{
|
|
return '@ChillPerson/Workflow/_accompanying_period_work.html.twig';
|
|
}
|
|
|
|
public function getTemplateData(EntityWorkflow $entityWorkflow, array $options = []): array
|
|
{
|
|
return [
|
|
'entity_workflow' => $entityWorkflow,
|
|
'work' => $this->getRelatedEntity($entityWorkflow),
|
|
];
|
|
}
|
|
|
|
public function getTemplateTitle(EntityWorkflow $entityWorkflow, array $options = []): string
|
|
{
|
|
return '@ChillPerson/Workflow/_accompanying_period_work.title.html.twig';
|
|
}
|
|
|
|
public function getTemplateTitleData(EntityWorkflow $entityWorkflow, array $options = []): array
|
|
{
|
|
return $this->getTemplateData($entityWorkflow, $options);
|
|
}
|
|
|
|
public function supports(EntityWorkflow $entityWorkflow, array $options = []): bool
|
|
{
|
|
return $entityWorkflow->getRelatedEntityClass() === AccompanyingPeriodWork::class;
|
|
}
|
|
|
|
public function supportsFreeze(EntityWorkflow $entityWorkflow, array $options = []): bool
|
|
{
|
|
return false;
|
|
}
|
|
}
|