mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
full generation for accompanying period
This commit is contained in:
@@ -13,12 +13,32 @@ namespace Chill\PersonBundle\Service\DocGenerator;
|
||||
|
||||
use Chill\DocGeneratorBundle\Context\DocGeneratorContextInterface;
|
||||
use Chill\DocGeneratorBundle\Context\Exception\UnexpectedTypeException;
|
||||
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
class AccompanyingPeriodContext implements DocGeneratorContextInterface
|
||||
{
|
||||
public NormalizerInterface $normalizer;
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
private NormalizerInterface $normalizer;
|
||||
|
||||
private TranslatableStringHelperInterface $translatableStringHelper;
|
||||
|
||||
public function __construct(
|
||||
NormalizerInterface $normalizer,
|
||||
TranslatableStringHelperInterface $translatableStringHelper,
|
||||
EntityManagerInterface $em
|
||||
) {
|
||||
$this->normalizer = $normalizer;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function getData($entity): array
|
||||
{
|
||||
@@ -49,6 +69,20 @@ class AccompanyingPeriodContext implements DocGeneratorContextInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccompanyingPeriod $entity
|
||||
*/
|
||||
public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity): void
|
||||
{
|
||||
$doc = new AccompanyingCourseDocument();
|
||||
$doc->setTitle($this->translatableStringHelper->localize($template->getName()))
|
||||
->setDate(new DateTime())
|
||||
->setDescription($this->translatableStringHelper->localize($template->getName()))
|
||||
->setCourse($entity)
|
||||
->setObject($storedObject);
|
||||
$this->em->persist($doc);
|
||||
}
|
||||
|
||||
public function supports(string $entityClass): bool
|
||||
{
|
||||
return AccompanyingPeriod::class === $entityClass;
|
||||
|
Reference in New Issue
Block a user