Merge branch '331-manage-attachments-to-workflow' into 'master'

Add attachments to workflow

Closes #331

See merge request Chill-Projet/chill-bundles!764
This commit is contained in:
2025-02-03 21:15:00 +00:00
106 changed files with 3455 additions and 619 deletions

View File

@@ -60,9 +60,10 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
#[ORM\ManyToOne(targetEntity: DocGeneratorTemplate::class)]
private ?DocGeneratorTemplate $template = null;
#[Serializer\Groups(['read', 'write', 'accompanying_period_work_evaluation:create'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])]
private ?string $title = '';
/**
* Store the title only if the storedObject is not yet associated with the instance.
*/
private string $proxyTitle = '';
public function getAccompanyingPeriodWorkEvaluation(): ?AccompanyingPeriodWorkEvaluation
{
@@ -89,9 +90,10 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
return $this->template;
}
#[Serializer\Groups(['read'])]
public function getTitle(): ?string
{
return $this->title;
return (string) $this->getStoredObject()?->getTitle();
}
public function setAccompanyingPeriodWorkEvaluation(?AccompanyingPeriodWorkEvaluation $accompanyingPeriodWorkEvaluation): AccompanyingPeriodWorkEvaluationDocument
@@ -125,6 +127,10 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
{
$this->storedObject = $storedObject;
if ('' !== $this->proxyTitle) {
$this->storedObject->setTitle($this->proxyTitle);
}
return $this;
}
@@ -135,9 +141,14 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
return $this;
}
public function setTitle(?string $title): AccompanyingPeriodWorkEvaluationDocument
#[Serializer\Groups(['write', 'accompanying_period_work_evaluation:create'])]
public function setTitle(?string $proxyTitle): AccompanyingPeriodWorkEvaluationDocument
{
$this->title = $title;
if (null !== $this->storedObject) {
$this->storedObject->setTitle((string) $proxyTitle);
} else {
$this->proxyTitle = (string) $proxyTitle;
}
return $this;
}

View File

@@ -1,83 +1,3 @@
{% import "@ChillDocStore/Macro/macro.html.twig" as m %}
{% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %}
{% import '@ChillPerson/Macro/updatedBy.html.twig' as mmm %}
{% set w = document.accompanyingPeriodWorkEvaluation.accompanyingPeriodWork %}
<div class="item-bloc">
<div class="item-row">
<div class="item-col" style="width: unset">
{% if document.storedObject.isPending %}
<div class="badge text-bg-info" data-docgen-is-pending="{{ document.storedObject.id }}">{{ 'docgen.Doc generation is pending'|trans }}</div>
{% elseif document.storedObject.isFailure %}
<div class="badge text-bg-warning">{{ 'docgen.Doc generation failed'|trans }}</div>
{% endif %}
<div>
{% if context == 'person' %}
<span class="badge bg-primary">
<i class="fa fa-random"></i> {{ w.accompanyingPeriod.id }}
</span>&nbsp;
{% endif %}
<div class="badge-accompanying-work-type">
<span class="title_label"></span>
<span class="title_action">{{ w.socialAction|chill_entity_render_string }} > {{ document.accompanyingPeriodWorkEvaluation.evaluation.title|localize_translatable_string }}</span>
</div>
</div>
<div class="denomination h2">
{{ document.title|chill_print_or_message("No title") }}
</div>
{% if document.storedObject.type is not empty %}
<div>
{{ mm.mimeIcon(document.storedObject.type) }}
</div>
{% endif %}
{% if document.storedObject.hasTemplate %}
<div>
<p>{{ document.storedObject.template.name|localize_translatable_string }}</p>
</div>
{% endif %}
</div>
<div class="item-col">
<div class="container">
<div class="dates row text-end">
<span>{{ document.storedObject.createdAt|format_date('short') }}</span>
</div>
</div>
</div>
</div>
<div class="item-row separator">
<div class="item-col item-meta">
{{ mmm.createdBy(document) }}
</div>
<ul class="item-col record_actions flex-shrink-1">
<li>
{{ chill_entity_workflow_list('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', document.id) }}
</li>
{% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_DOCUMENT_SHOW', document) %}
<li>
{{ document.storedObject|chill_document_button_group(document.title, is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', document.accompanyingPeriodWorkEvaluation.accompanyingPeriodWork)) }}
</li>
{% endif %}
{% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w) %}
<li>
<form method="post" action="{{ chill_path_add_return_path('chill_person_accompanying_period_work_evaluation_document_duplicate', {id: document.id}) }}">
<button type="submit" class="btn btn-duplicate" title="{{ 'crud.view.link_duplicate'|trans }}"></button>
</form>
</li>
{% endif %}
{% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w) %}
<li>
<a href="{{ chill_path_add_return_path('chill_person_accompanying_period_work_edit', {'id': w.id, 'docId': document.id}) }}" class="btn btn-edit"></a>
</li>
{% endif %}
{% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_SEE', w)%}
<li>
<a href="{{ chill_path_add_return_path('chill_person_accompanying_period_work_show', {'id': w.id, 'docId': document.id}) }}" class="btn btn-show"></a>
</li>
{% endif %}
</ul>
</div>
{{ include('@ChillPerson/GenericDoc/evaluation_document_row.html.twig') }}
</div>

View File

@@ -0,0 +1,82 @@
{% import "@ChillDocStore/Macro/macro.html.twig" as m %}
{% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %}
{% import '@ChillPerson/Macro/updatedBy.html.twig' as mmm %}
{% set w = document.accompanyingPeriodWorkEvaluation.accompanyingPeriodWork %}
<div class="item-row">
<div class="item-col" style="width: unset">
{% if document.storedObject.isPending %}
<div class="badge text-bg-info" data-docgen-is-pending="{{ document.storedObject.id }}">{{ 'docgen.Doc generation is pending'|trans }}</div>
{% elseif document.storedObject.isFailure %}
<div class="badge text-bg-warning">{{ 'docgen.Doc generation failed'|trans }}</div>
{% endif %}
<div>
{% if context == 'person' %}
<span class="badge bg-primary">
<i class="fa fa-random"></i> {{ w.accompanyingPeriod.id }}
</span>&nbsp;
{% endif %}
<div class="badge-accompanying-work-type">
<span class="title_label"></span>
<span class="title_action">{{ w.socialAction|chill_entity_render_string }} > {{ document.accompanyingPeriodWorkEvaluation.evaluation.title|localize_translatable_string }}</span>
</div>
</div>
<div class="denomination h2">
{{ document.title|chill_print_or_message("No title") }}
</div>
{% if document.storedObject.type is not empty %}
<div>
{{ mm.mimeIcon(document.storedObject.type) }}
</div>
{% endif %}
{% if document.storedObject.hasTemplate %}
<div>
<p>{{ document.storedObject.template.name|localize_translatable_string }}</p>
</div>
{% endif %}
</div>
<div class="item-col">
<div class="container">
<div class="dates row text-end">
<span>{{ document.storedObject.createdAt|format_date('short') }}</span>
</div>
</div>
</div>
</div>
{% if show_actions %}
<div class="item-row separator">
<div class="item-col item-meta">
{{ mmm.createdBy(document) }}
</div>
<ul class="item-col record_actions flex-shrink-1">
<li>
{{ chill_entity_workflow_list('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', document.id) }}
</li>
{% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_DOCUMENT_SHOW', document) %}
<li>
{{ document.storedObject|chill_document_button_group(document.title, is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', document.accompanyingPeriodWorkEvaluation.accompanyingPeriodWork)) }}
</li>
{% endif %}
{% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w) %}
<li>
<form method="post" action="{{ chill_path_add_return_path('chill_person_accompanying_period_work_evaluation_document_duplicate', {id: document.id}) }}">
<button type="submit" class="btn btn-duplicate" title="{{ 'crud.view.link_duplicate'|trans }}"></button>
</form>
</li>
{% endif %}
{% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w) %}
<li>
<a href="{{ chill_path_add_return_path('chill_person_accompanying_period_work_edit', {'id': w.id, 'docId': document.id}) }}" class="btn btn-edit"></a>
</li>
{% endif %}
{% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_SEE', w)%}
<li>
<a href="{{ chill_path_add_return_path('chill_person_accompanying_period_work_show', {'id': w.id, 'docId': document.id}) }}" class="btn btn-show"></a>
</li>
{% endif %}
</ul>
</div>
{% endif %}

View File

@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/*
* 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.
*/
namespace Chill\PersonBundle\Service\GenericDoc\Normalizer;
use Chill\DocStoreBundle\GenericDoc\GenericDocDTO;
use Chill\DocStoreBundle\GenericDoc\GenericDocNormalizerInterface;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocumentRepository;
use Chill\PersonBundle\Service\GenericDoc\Providers\AccompanyingPeriodWorkEvaluationGenericDocProvider;
use Chill\PersonBundle\Service\GenericDoc\Renderer\AccompanyingPeriodWorkEvaluationGenericDocRenderer;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Environment;
final readonly class AccompanyingPeriodWorkEvaluationGenericDocNormalizer implements GenericDocNormalizerInterface
{
public function __construct(
private AccompanyingPeriodWorkEvaluationDocumentRepository $accompanyingPeriodWorkEvaluationDocumentRepository,
private Environment $twig,
private AccompanyingPeriodWorkEvaluationGenericDocRenderer $renderer,
private TranslatorInterface $translator,
) {}
public function supportsNormalization(GenericDocDTO $genericDocDTO, string $format, array $context = []): bool
{
return AccompanyingPeriodWorkEvaluationGenericDocProvider::KEY === $genericDocDTO->key;
}
public function normalize(GenericDocDTO $genericDocDTO, string $format, array $context = []): array
{
if (null === $evaluationDoc = $this->accompanyingPeriodWorkEvaluationDocumentRepository->find($genericDocDTO->identifiers['id'])) {
return ['title' => $this->translator->trans('generic_doc.document removed'), 'isPresent' => false];
}
return [
'title' => $evaluationDoc->getTitle(),
'html' => $this->twig->render(
$this->renderer->getTemplate($genericDocDTO, ['show-actions' => false, 'row-only' => true]),
$this->renderer->getTemplateData($genericDocDTO, ['show-actions' => false, 'row-only' => true])
),
'isPresent' => true,
];
}
}

View File

@@ -14,10 +14,12 @@ namespace Chill\PersonBundle\Service\GenericDoc\Providers;
use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\DocStoreBundle\GenericDoc\FetchQuery;
use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface;
use Chill\DocStoreBundle\GenericDoc\GenericDocDTO;
use Chill\DocStoreBundle\GenericDoc\GenericDocForAccompanyingPeriodProviderInterface;
use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocumentRepository;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkVoter;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\EntityManagerInterface;
@@ -30,8 +32,38 @@ final readonly class AccompanyingPeriodWorkEvaluationGenericDocProvider implemen
public function __construct(
private Security $security,
private EntityManagerInterface $entityManager,
private AccompanyingPeriodWorkEvaluationDocumentRepository $accompanyingPeriodWorkEvaluationDocumentRepository,
) {}
public function fetchAssociatedStoredObject(GenericDocDTO $genericDocDTO): ?StoredObject
{
return $this->accompanyingPeriodWorkEvaluationDocumentRepository->find($genericDocDTO->identifiers['id'])?->getStoredObject();
}
public function supportsGenericDoc(GenericDocDTO $genericDocDTO): bool
{
return $this->supportsKeyAndIdentifiers($genericDocDTO->key, $genericDocDTO->identifiers);
}
public function supportsKeyAndIdentifiers(string $key, array $identifiers): bool
{
return self::KEY === $key;
}
public function buildOneGenericDoc(string $key, array $identifiers): ?GenericDocDTO
{
if (null === $document = $this->accompanyingPeriodWorkEvaluationDocumentRepository->find($identifiers['id'])) {
return null;
}
return new GenericDocDTO(
$key,
$identifiers,
$document->getAccompanyingPeriodWorkEvaluation()->getCreatedAt(),
$document->getAccompanyingPeriodWorkEvaluation()->getAccompanyingPeriodWork()->getAccompanyingPeriod()
);
}
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
{
$accompanyingPeriodWorkMetadata = $this->entityManager->getClassMetadata(AccompanyingPeriod\AccompanyingPeriodWork::class);
@@ -53,7 +85,6 @@ final readonly class AccompanyingPeriodWorkEvaluationGenericDocProvider implemen
private function addWhereClausesToQuery(FetchQuery $query, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery
{
$classMetadata = $this->entityManager->getClassMetadata(AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument::class);
$storedObjectMetadata = $this->entityManager->getClassMetadata(StoredObject::class);
if (null !== $startDate) {
@@ -74,7 +105,7 @@ final readonly class AccompanyingPeriodWorkEvaluationGenericDocProvider implemen
if (null !== $content) {
$query->addWhereClause(
sprintf('apwed.%s ilike ?', $classMetadata->getColumnName('title')),
sprintf('doc_store.%s ilike ?', $storedObjectMetadata->getColumnName('title')),
['%'.$content.'%'],
[Types::STRING]
);

View File

@@ -16,6 +16,9 @@ use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocumentRepository;
use Chill\PersonBundle\Service\GenericDoc\Providers\AccompanyingPeriodWorkEvaluationGenericDocProvider;
/**
* @implements GenericDocRendererInterface<array{row-only?: bool, show-actions?: bool}>
*/
final readonly class AccompanyingPeriodWorkEvaluationGenericDocRenderer implements GenericDocRendererInterface
{
public function __construct(
@@ -29,7 +32,8 @@ final readonly class AccompanyingPeriodWorkEvaluationGenericDocRenderer implemen
public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string
{
return '@ChillPerson/GenericDoc/evaluation_document.html.twig';
return ($options['row-only'] ?? false) ? '@ChillPerson/GenericDoc/evaluation_document_row.html.twig'
: '@ChillPerson/GenericDoc/evaluation_document.html.twig';
}
public function getTemplateData(GenericDocDTO $genericDocDTO, $options = []): array
@@ -37,6 +41,7 @@ final readonly class AccompanyingPeriodWorkEvaluationGenericDocRenderer implemen
return [
'document' => $this->accompanyingPeriodWorkEvaluationDocumentRepository->find($genericDocDTO->identifiers['id']),
'context' => $genericDocDTO->getContext(),
'show_actions' => $options['show-actions'] ?? true,
];
}
}

View File

@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Service\GenericDoc\Providers;
use Chill\CalendarBundle\Repository\CalendarDocRepositoryInterface;
use Chill\CalendarBundle\Security\Voter\CalendarVoter;
use Chill\CalendarBundle\Service\GenericDoc\Providers\AccompanyingPeriodCalendarGenericDocProvider;
use Chill\DocStoreBundle\GenericDoc\FetchQueryToSqlBuilder;
@@ -35,11 +36,14 @@ class AccompanyingPeriodCalendarGenericDocProviderTest extends KernelTestCase
private EntityManagerInterface $entityManager;
private CalendarDocRepositoryInterface $calendarDocRepository;
protected function setUp(): void
{
self::bootKernel();
$this->security = self::getContainer()->get(Security::class);
$this->entityManager = self::getContainer()->get(EntityManagerInterface::class);
$this->calendarDocRepository = self::getContainer()->get(CalendarDocRepositoryInterface::class);
}
/**
@@ -47,7 +51,7 @@ class AccompanyingPeriodCalendarGenericDocProviderTest extends KernelTestCase
*/
public function testBuildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?string $content): void
{
$provider = new AccompanyingPeriodCalendarGenericDocProvider($this->security, $this->entityManager);
$provider = new AccompanyingPeriodCalendarGenericDocProvider($this->security, $this->entityManager, $this->calendarDocRepository);
$query = $provider->buildFetchQueryForAccompanyingPeriod($accompanyingPeriod, $startDate, $endDate, $content);
@@ -66,7 +70,7 @@ class AccompanyingPeriodCalendarGenericDocProviderTest extends KernelTestCase
$security = $this->prophesize(Security::class);
$security->isGranted(CalendarVoter::SEE, Argument::any())->willReturn(true);
$provider = new AccompanyingPeriodCalendarGenericDocProvider($security->reveal(), $this->entityManager);
$provider = new AccompanyingPeriodCalendarGenericDocProvider($security->reveal(), $this->entityManager, $this->calendarDocRepository);
$query = $provider->buildFetchQueryForPerson($person, $startDate, $endDate, $content);
@@ -87,7 +91,7 @@ class AccompanyingPeriodCalendarGenericDocProviderTest extends KernelTestCase
$security = $this->prophesize(Security::class);
$security->isGranted(CalendarVoter::SEE, Argument::any())->willReturn(false);
$provider = new AccompanyingPeriodCalendarGenericDocProvider($security->reveal(), $this->entityManager);
$provider = new AccompanyingPeriodCalendarGenericDocProvider($security->reveal(), $this->entityManager, $this->calendarDocRepository);
$query = $provider->buildFetchQueryForPerson($person, $startDate, $endDate, $content);

View File

@@ -9,10 +9,11 @@ declare(strict_types=1);
* the LICENSE file that was distributed with this source code.
*/
namespace Service\GenericDoc\Providers;
namespace Chill\PersonBundle\Tests\Service\GenericDoc\Providers;
use Chill\DocStoreBundle\GenericDoc\FetchQueryToSqlBuilder;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocumentRepository;
use Chill\PersonBundle\Service\GenericDoc\Providers\AccompanyingPeriodWorkEvaluationGenericDocProvider;
use Doctrine\ORM\EntityManagerInterface;
use Prophecy\PhpUnit\ProphecyTrait;
@@ -29,10 +30,13 @@ class AccompanyingPeriodWorkEvaluationGenericDocProviderTest extends KernelTestC
use ProphecyTrait;
private EntityManagerInterface $entityManager;
private AccompanyingPeriodWorkEvaluationDocumentRepository $repository;
protected function setUp(): void
{
self::bootKernel();
$this->entityManager = self::getContainer()->get(EntityManagerInterface::class);
$this->repository = self::getContainer()->get(AccompanyingPeriodWorkEvaluationDocumentRepository::class);
}
/**
@@ -55,7 +59,8 @@ class AccompanyingPeriodWorkEvaluationGenericDocProviderTest extends KernelTestC
$provider = new AccompanyingPeriodWorkEvaluationGenericDocProvider(
$security->reveal(),
$this->entityManager
$this->entityManager,
$this->repository,
);
$query = $provider->buildFetchQueryForAccompanyingPeriod($period, $startDate, $endDate, $content);

View File

@@ -20,6 +20,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\MainBundle\Workflow\EntityWorkflowWithPublicViewInterface;
use Chill\MainBundle\Workflow\EntityWorkflowWithStoredObjectHandlerInterface;
use Chill\MainBundle\Workflow\Templating\EntityWorkflowViewMetadataDTO;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocumentRepository;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkEvaluationDocumentVoter;
@@ -85,6 +86,12 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW
return $this->repository->find($entityWorkflow->getRelatedEntityId());
}
public function getRelatedAccompanyingPeriod(EntityWorkflow $entityWorkflow): ?AccompanyingPeriod
{
return $this->getRelatedEntity($entityWorkflow)?->getAccompanyingPeriodWorkEvaluation()->getAccompanyingPeriodWork()
->getAccompanyingPeriod();
}
/**
* @return array[]
*/

View File

@@ -15,6 +15,7 @@ use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationRepository;
@@ -66,6 +67,11 @@ readonly class AccompanyingPeriodWorkEvaluationWorkflowHandler implements Entity
return $this->repository->find($entityWorkflow->getRelatedEntityId());
}
public function getRelatedAccompanyingPeriod(EntityWorkflow $entityWorkflow): ?AccompanyingPeriod
{
return $this->getRelatedEntity($entityWorkflow)?->getAccompanyingPeriodWork()->getAccompanyingPeriod();
}
public function getRelatedObjects(object $object): array
{
$relateds = [];

View File

@@ -15,6 +15,7 @@ use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
@@ -68,6 +69,11 @@ readonly class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHa
return $this->repository->find($entityWorkflow->getRelatedEntityId());
}
public function getRelatedAccompanyingPeriod(EntityWorkflow $entityWorkflow): ?AccompanyingPeriod
{
return $this->getRelatedEntity($entityWorkflow)?->getAccompanyingPeriod();
}
public function getRelatedObjects(object $object): array
{
$relateds = [];

View File

@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
/*
* 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.
*/
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20241212120202 extends AbstractMigration
{
public function getDescription(): string
{
return 'Move the title from accompanying period work evaluation document to stored object';
}
public function up(Schema $schema): void
{
$this->addSql('UPDATE chill_doc.stored_object SET title = doc.title FROM chill_person_accompanying_period_work_evaluation_document doc WHERE storedobject_id = stored_object.id');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document DROP title');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ADD title TEXT DEFAULT \'\' NOT NULL');
$this->addSql('UPDATE chill_person_accompanying_period_work_evaluation_document SET title = so.title FROM chill_doc.stored_object so WHERE storedobject_id = so.id');
}
}