mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-19 08:44:24 +00:00
117 lines
3.4 KiB
PHP
117 lines
3.4 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\Service\DocGenerator;
|
|
|
|
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
|
use Chill\DocStoreBundle\Entity\StoredObject;
|
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
|
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
|
|
|
class AccompanyingPeriodWorkContext
|
|
{
|
|
private NormalizerInterface $normalizer;
|
|
|
|
private AccompanyingPeriodContext $periodContext;
|
|
|
|
public function __construct(
|
|
AccompanyingPeriodContext $periodContext,
|
|
NormalizerInterface $normalizer
|
|
) {
|
|
$this->periodContext = $periodContext;
|
|
$this->normalizer = $normalizer;
|
|
}
|
|
|
|
public function adminFormReverseTransform(array $data): array
|
|
{
|
|
return $this->periodContext->adminFormReverseTransform($data);
|
|
}
|
|
|
|
public function adminFormTransform(array $data): array
|
|
{
|
|
return $this->periodContext->adminFormTransform($data);
|
|
}
|
|
|
|
public function buildAdminForm(FormBuilderInterface $builder): void
|
|
{
|
|
$this->periodContext->buildAdminForm($builder);
|
|
|
|
$builder->remove('category');
|
|
}
|
|
|
|
/**
|
|
* @param AccompanyingPeriodWork $entity
|
|
*/
|
|
public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, $entity): void
|
|
{
|
|
$this->periodContext->buildPublicForm($builder, $template, $entity->getAccompanyingPeriod());
|
|
}
|
|
|
|
/**
|
|
* @param AccompanyingPeriodWork $entity
|
|
*/
|
|
public function getData(DocGeneratorTemplate $template, $entity, array $contextGenerationData = []): array
|
|
{
|
|
$data = $this->periodContext->getData($template, $entity->getAccompanyingPeriod(), $contextGenerationData);
|
|
$data['work'] = $this->normalizer->normalize($entity, 'docgen', [
|
|
AbstractNormalizer::GROUPS => ['docgen:read'],
|
|
'docgen:expects' => AccompanyingPeriodWork::class,
|
|
]);
|
|
|
|
return $data;
|
|
}
|
|
|
|
public function getDescription(): string
|
|
{
|
|
return 'docgen.A context for accompanying period work';
|
|
}
|
|
|
|
public function getEntityClass(): string
|
|
{
|
|
return AccompanyingPeriodWork::class;
|
|
}
|
|
|
|
/**
|
|
* @param AccompanyingPeriodWork $entity
|
|
*/
|
|
public function getFormData(DocGeneratorTemplate $template, $entity): array
|
|
{
|
|
return $this->periodContext->getFormData($template, $entity->getAccompanyingPeriod());
|
|
}
|
|
|
|
public static function getKey(): string
|
|
{
|
|
return 'accompanying_period_work_regular';
|
|
}
|
|
|
|
public function getName(): string
|
|
{
|
|
return 'docgen.Accompanying period work';
|
|
}
|
|
|
|
public function hasAdminForm(): bool
|
|
{
|
|
return $this->periodContext->hasAdminForm();
|
|
}
|
|
|
|
public function hasPublicForm(DocGeneratorTemplate $template, $entity): bool
|
|
{
|
|
return $this->periodContext->hasPublicForm($template, $entity);
|
|
}
|
|
|
|
public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void
|
|
{
|
|
// TODO: Implement storeGenerated() method.
|
|
}
|
|
}
|