mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 07:33:50 +00:00
add docgen context for AccompanyingPeriodWork
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\Service\DocGenerator;
|
||||
|
||||
use Chill\DocGeneratorBundle\Context\DocGeneratorContextInterface;
|
||||
use Chill\DocGeneratorBundle\Context\DocGeneratorContextWithAdminFormInterface;
|
||||
use Chill\DocGeneratorBundle\Context\DocGeneratorContextWithPublicFormInterface;
|
||||
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 implements
|
||||
DocGeneratorContextInterface,
|
||||
DocGeneratorContextWithAdminFormInterface,
|
||||
DocGeneratorContextWithPublicFormInterface
|
||||
{
|
||||
private AccompanyingPeriodContext $periodContext;
|
||||
|
||||
private NormalizerInterface $normalizer;
|
||||
|
||||
public function __construct(
|
||||
AccompanyingPeriodContext $periodContext,
|
||||
NormalizerInterface $normalizer
|
||||
) {
|
||||
$this->periodContext = $periodContext;
|
||||
$this->normalizer = $normalizer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 "A context for work";
|
||||
}
|
||||
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return AccompanyingPeriodWork::class;
|
||||
}
|
||||
|
||||
public static function getKey(): string
|
||||
{
|
||||
return 'accompanying_period_work_regular';
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return "Accompanying period work";
|
||||
}
|
||||
|
||||
public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void
|
||||
{
|
||||
// TODO: Implement storeGenerated() method.
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public function hasAdminForm(): bool
|
||||
{
|
||||
return $this->periodContext->hasAdminForm();
|
||||
}
|
||||
|
||||
public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, $entity): void
|
||||
{
|
||||
$this->periodContext->buildPublicForm($builder, $template, $entity);
|
||||
}
|
||||
|
||||
public function hasPublicForm(DocGeneratorTemplate $template, $entity): bool
|
||||
{
|
||||
return $this->periodContext->hasPublicForm($template, $entity);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user