mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
create contextmanager and refactor docgeneratorTemplateType
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\Service\DocGenerator;
|
||||
|
||||
use Chill\DocGeneratorBundle\Context\DocGeneratorContextInterface;
|
||||
use Chill\DocGeneratorBundle\Context\Exception\UnexpectedTypeException;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
class AccompanyingPeriodContext implements DocGeneratorContextInterface
|
||||
{
|
||||
public NormalizerInterface $normalizer;
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Accompanying Period';
|
||||
}
|
||||
|
||||
public static function getKey(): string
|
||||
{
|
||||
return self::class;
|
||||
}
|
||||
|
||||
public function getData($entity): array
|
||||
{
|
||||
if (!$entity instanceof AccompanyingPeriod) {
|
||||
throw new UnexpectedTypeException($entity, AccompanyingPeriod::class);
|
||||
}
|
||||
|
||||
return $this->normalizer->normalize($entity, 'docgen', ['docgen:expects' => AccompanyingPeriod::class]);
|
||||
}
|
||||
|
||||
public function getForm($entity)
|
||||
{
|
||||
// TODO: Implement getForm() method.
|
||||
}
|
||||
|
||||
public function hasForm(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function supports(string $entityClass): bool
|
||||
{
|
||||
return $entityClass === AccompanyingPeriod::class;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user