mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 22:04:23 +00:00
full generation for accompanying period
This commit is contained in:
parent
9d0e1a82e7
commit
7719d2b073
@ -11,8 +11,14 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\DocGeneratorBundle\Context;
|
namespace Chill\DocGeneratorBundle\Context;
|
||||||
|
|
||||||
|
use Chill\DocGeneratorBundle\Context\Exception\ContextNotFoundException;
|
||||||
|
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||||
|
|
||||||
class ContextManager
|
class ContextManager
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var DocGeneratorContextInterface[]|iterable
|
||||||
|
*/
|
||||||
private iterable $contexts;
|
private iterable $contexts;
|
||||||
|
|
||||||
public function __construct(iterable $contexts)
|
public function __construct(iterable $contexts)
|
||||||
@ -20,7 +26,21 @@ class ContextManager
|
|||||||
$this->contexts = $contexts;
|
$this->contexts = $contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getContext(): array
|
/**
|
||||||
|
* @throw ContextNotFoundException when the context is not found
|
||||||
|
*/
|
||||||
|
public function getContextByDocGeneratorTemplate(DocGeneratorTemplate $docGeneratorTemplate): DocGeneratorContextInterface
|
||||||
|
{
|
||||||
|
foreach ($this->contexts as $key => $context) {
|
||||||
|
if ($docGeneratorTemplate->getContext() === $key) {
|
||||||
|
return $context;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ContextNotFoundException($docGeneratorTemplate->getContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getContexts(): array
|
||||||
{
|
{
|
||||||
return iterator_to_array($this->contexts);
|
return iterator_to_array($this->contexts);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\DocGeneratorBundle\Context;
|
namespace Chill\DocGeneratorBundle\Context;
|
||||||
|
|
||||||
|
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||||
|
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for context for for document generation.
|
* Interface for context for for document generation.
|
||||||
*/
|
*/
|
||||||
@ -39,6 +42,8 @@ interface DocGeneratorContextInterface
|
|||||||
*/
|
*/
|
||||||
public function hasForm(): bool;
|
public function hasForm(): bool;
|
||||||
|
|
||||||
|
public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True of false which entity supports.
|
* True of false which entity supports.
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
<?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\DocGeneratorBundle\Context\Exception;
|
||||||
|
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
|
class ContextNotFoundException extends RuntimeException
|
||||||
|
{
|
||||||
|
public function __construct($contextName)
|
||||||
|
{
|
||||||
|
parent::__construct(sprintf('the context with name %s is not found', $contextName));
|
||||||
|
}
|
||||||
|
}
|
@ -11,9 +11,13 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\DocGeneratorBundle\Context;
|
namespace Chill\DocGeneratorBundle\Context;
|
||||||
|
|
||||||
|
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||||
|
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
|
||||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Exception;
|
use Exception;
|
||||||
use function count;
|
use function count;
|
||||||
use function get_class;
|
use function get_class;
|
||||||
@ -23,6 +27,13 @@ use function get_class;
|
|||||||
*/
|
*/
|
||||||
class HouseholdMemberSelectionContext implements DocGeneratorContextInterface
|
class HouseholdMemberSelectionContext implements DocGeneratorContextInterface
|
||||||
{
|
{
|
||||||
|
private EntityManagerInterface $em;
|
||||||
|
|
||||||
|
public function __construct(EntityManagerInterface $em)
|
||||||
|
{
|
||||||
|
$this->em = $em;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the data that will be injected to the generated document.
|
* Get the data that will be injected to the generated document.
|
||||||
*
|
*
|
||||||
@ -107,6 +118,19 @@ class HouseholdMemberSelectionContext implements DocGeneratorContextInterface
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity): void
|
||||||
|
{
|
||||||
|
// Only for evaluation
|
||||||
|
if ($entity instanceof AccompanyingPeriodWorkEvaluation) {
|
||||||
|
$doc = new AccompanyingPeriodWorkEvaluationDocument();
|
||||||
|
$doc
|
||||||
|
->setStoredObject($storedObject)
|
||||||
|
->setTemplate($template);
|
||||||
|
$entity->addDocument($doc);
|
||||||
|
$this->em->persist($doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True of false which entity supports.
|
* True of false which entity supports.
|
||||||
*/
|
*/
|
||||||
|
@ -13,25 +13,24 @@ namespace Chill\DocGeneratorBundle\Controller;
|
|||||||
|
|
||||||
use Base64Url\Base64Url;
|
use Base64Url\Base64Url;
|
||||||
use ChampsLibres\AsyncUploaderBundle\TempUrl\TempUrlGeneratorInterface;
|
use ChampsLibres\AsyncUploaderBundle\TempUrl\TempUrlGeneratorInterface;
|
||||||
use Chill\DocGeneratorBundle\Context\HouseholdMemberSelectionContext;
|
use Chill\DocGeneratorBundle\Context\ContextManager;
|
||||||
|
use Chill\DocGeneratorBundle\Context\Exception\ContextNotFoundException;
|
||||||
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||||
use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository;
|
use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository;
|
||||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||||
use Chill\MainBundle\Serializer\Model\Collection;
|
use Chill\MainBundle\Serializer\Model\Collection;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
|
|
||||||
|
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use GuzzleHttp\Exception\TransferException;
|
use GuzzleHttp\Exception\TransferException;
|
||||||
use PhpOffice\PhpWord\TemplateProcessor;
|
use PhpOffice\PhpWord\TemplateProcessor;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
// TODO à mettre dans services
|
// TODO à mettre dans services
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Symfony\Component\HttpKernel\KernelInterface;
|
use Symfony\Component\HttpKernel\KernelInterface;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||||
@ -42,20 +41,32 @@ final class DocGeneratorTemplateController extends AbstractController
|
|||||||
{
|
{
|
||||||
private HttpClientInterface $client;
|
private HttpClientInterface $client;
|
||||||
|
|
||||||
|
private ContextManager $contextManager;
|
||||||
|
|
||||||
private DocGeneratorTemplateRepository $docGeneratorTemplateRepository;
|
private DocGeneratorTemplateRepository $docGeneratorTemplateRepository;
|
||||||
|
|
||||||
private KernelInterface $kernel;
|
private KernelInterface $kernel;
|
||||||
|
|
||||||
|
private LoggerInterface $logger;
|
||||||
|
|
||||||
private PaginatorFactory $paginatorFactory;
|
private PaginatorFactory $paginatorFactory;
|
||||||
|
|
||||||
|
private TempUrlGeneratorInterface $tempUrlGenerator;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
ContextManager $contextManager,
|
||||||
DocGeneratorTemplateRepository $docGeneratorTemplateRepository,
|
DocGeneratorTemplateRepository $docGeneratorTemplateRepository,
|
||||||
|
LoggerInterface $logger,
|
||||||
PaginatorFactory $paginatorFactory,
|
PaginatorFactory $paginatorFactory,
|
||||||
|
TempUrlGeneratorInterface $tempUrlGenerator,
|
||||||
KernelInterface $kernel,
|
KernelInterface $kernel,
|
||||||
HttpClientInterface $client
|
HttpClientInterface $client
|
||||||
) {
|
) {
|
||||||
|
$this->contextManager = $contextManager;
|
||||||
$this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository;
|
$this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository;
|
||||||
|
$this->logger = $logger;
|
||||||
$this->paginatorFactory = $paginatorFactory;
|
$this->paginatorFactory = $paginatorFactory;
|
||||||
|
$this->tempUrlGenerator = $tempUrlGenerator;
|
||||||
$this->kernel = $kernel;
|
$this->kernel = $kernel;
|
||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
}
|
}
|
||||||
@ -67,13 +78,12 @@ final class DocGeneratorTemplateController extends AbstractController
|
|||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
public function generateDocFromTemplateAction(
|
public function generateDocFromTemplateAction(
|
||||||
TempUrlGeneratorInterface $tempUrlGenerator,
|
|
||||||
DocGeneratorTemplate $template,
|
DocGeneratorTemplate $template,
|
||||||
string $entityClassName,
|
string $entityClassName,
|
||||||
int $entityId,
|
int $entityId,
|
||||||
Request $request
|
Request $request
|
||||||
): Response {
|
): Response {
|
||||||
$getUrlGen = $tempUrlGenerator->generate(
|
$getUrlGen = $this->tempUrlGenerator->generate(
|
||||||
'GET',
|
'GET',
|
||||||
$template->getFile()->getFilename()
|
$template->getFile()->getFilename()
|
||||||
);
|
);
|
||||||
@ -102,25 +112,29 @@ final class DocGeneratorTemplateController extends AbstractController
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fwrite($handle, $dataDecrypted) === false) {
|
if (false === $ftemplate = fwrite($handle, $dataDecrypted)) {
|
||||||
echo "Cannot write to file ({$tmpfnameDeCrypted})";
|
echo "Cannot write to file ({$tmpfnameDeCrypted})";
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
dump("Success, wrote ({$dataDecrypted}) to file ({$tmpfnameDeCrypted})");
|
dump("Success, wrote (to file ({$tmpfnameDeCrypted})");
|
||||||
|
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
|
|
||||||
$entity = $this->getDoctrine()->getRepository($entityClassName)->find($entityId);
|
$entity = $this->getDoctrine()->getRepository($entityClassName)->find($entityId);
|
||||||
|
|
||||||
if ($template->getContext() === HouseholdMemberSelectionContext::class) {
|
try {
|
||||||
$context = new HouseholdMemberSelectionContext();
|
$context = $this->contextManager->getContextByDocGeneratorTemplate($template);
|
||||||
$datas = $context->getData($entity);
|
} catch (ContextNotFoundException $e) {
|
||||||
} else {
|
throw new NotFoundHttpException($e->getMessage(), $e);
|
||||||
throw new \Exception('Not implemented', 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$datas = $context->getData($entity);
|
||||||
|
|
||||||
|
dump('process the data', $datas);
|
||||||
|
|
||||||
|
/*
|
||||||
$templateProcessor = new TemplateProcessor($tmpfnameDeCrypted);
|
$templateProcessor = new TemplateProcessor($tmpfnameDeCrypted);
|
||||||
|
|
||||||
foreach ($datas['setValues'] as $setValuesConf) {
|
foreach ($datas['setValues'] as $setValuesConf) {
|
||||||
@ -130,28 +144,32 @@ final class DocGeneratorTemplateController extends AbstractController
|
|||||||
foreach ($datas['cloneRowAndSetValues'] as $cloneRowAndSetValues) {
|
foreach ($datas['cloneRowAndSetValues'] as $cloneRowAndSetValues) {
|
||||||
$templateProcessor->cloneRowAndSetValues($cloneRowAndSetValues[0], $cloneRowAndSetValues[1]);
|
$templateProcessor->cloneRowAndSetValues($cloneRowAndSetValues[0], $cloneRowAndSetValues[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmpfnameGenerated = tempnam($this->kernel->getCacheDir(), 'DOC_GENERATED');
|
$tmpfnameGenerated = tempnam($this->kernel->getCacheDir(), 'DOC_GENERATED');
|
||||||
$templateProcessor->saveAs($tmpfnameGenerated);
|
|
||||||
|
|
||||||
$fileContent = fopen($tmpfnameGenerated, 'rb'); // the generated file content
|
$fileContent = fopen($tmpfnameGenerated, 'rb'); // the generated file content
|
||||||
|
*/
|
||||||
|
|
||||||
$genDocName = 'doc_' . sprintf('%010d', mt_rand()) . '.docx';
|
$genDocName = 'doc_' . sprintf('%010d', mt_rand()) . '.docx';
|
||||||
|
|
||||||
$getUrlGen = $tempUrlGenerator->generate(
|
$getUrlGen = $this->tempUrlGenerator->generate(
|
||||||
'PUT',
|
'PUT',
|
||||||
$genDocName
|
$genDocName
|
||||||
);
|
);
|
||||||
|
|
||||||
unlink($tmpfnameDeCrypted);
|
unlink($tmpfnameDeCrypted);
|
||||||
unlink($tmpfnameGenerated);
|
//unlink($tmpfnameGenerated);
|
||||||
|
|
||||||
$client = new Client();
|
$client = new Client();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
/*
|
||||||
$putResponse = $client->request('PUT', $getUrlGen->url, [
|
$putResponse = $client->request('PUT', $getUrlGen->url, [
|
||||||
'body' => $fileContent,
|
'body' => $fileContent,
|
||||||
]);
|
]);
|
||||||
|
*/
|
||||||
|
$putResponse = $client->request('PUT', $getUrlGen->url, [
|
||||||
|
'body' => $ftemplate,
|
||||||
|
]);
|
||||||
|
|
||||||
if ($putResponse->getStatusCode() === 201) {
|
if ($putResponse->getStatusCode() === 201) {
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
@ -163,14 +181,16 @@ final class DocGeneratorTemplateController extends AbstractController
|
|||||||
|
|
||||||
$em->persist($storedObject);
|
$em->persist($storedObject);
|
||||||
|
|
||||||
// Only for evaluation
|
try {
|
||||||
if ($entity instanceof AccompanyingPeriodWorkEvaluation) {
|
$context->storeGenerated($template, $storedObject, $entity);
|
||||||
$doc = new AccompanyingPeriodWorkEvaluationDocument();
|
} catch (\Exception $e) {
|
||||||
$doc
|
$this->logger->error('Could not store the associated document to entity', [
|
||||||
->setStoredObject($storedObject)
|
'entityClassName' => $entityClassName,
|
||||||
->setTemplate($template);
|
'entityId' => $entityId,
|
||||||
$entity->addDocument($doc);
|
'contextKey' => $context->getName(),
|
||||||
$em->persist($doc);
|
]);
|
||||||
|
|
||||||
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
@ -184,7 +204,7 @@ final class DocGeneratorTemplateController extends AbstractController
|
|||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception('Unable to generate document.');
|
throw new \Exception('Unable to generate document.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +35,7 @@ class DocGeneratorTemplateType extends AbstractType
|
|||||||
{
|
{
|
||||||
$contexts = array_flip(array_map(static function (DocGeneratorContextInterface $c) {
|
$contexts = array_flip(array_map(static function (DocGeneratorContextInterface $c) {
|
||||||
return $c->getName();
|
return $c->getName();
|
||||||
}, $this->contextManager->getContext()));
|
}, $this->contextManager->getContexts()));
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
->add('name', TranslatableStringFormType::class, [
|
->add('name', TranslatableStringFormType::class, [
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
{% for document in documents %}
|
{% for document in documents %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ document.title }}</td>
|
<td>{{ document.title }}</td>
|
||||||
<td>{{ document.category.name|localize_translatable_string }}</td>
|
<td>{% if document.category %}{{ document.category.name|localize_translatable_string }}{% endif %}</td>
|
||||||
<td>
|
<td>
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
{% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE_DETAILS', document) %}
|
{% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE_DETAILS', document) %}
|
||||||
|
@ -22,8 +22,10 @@
|
|||||||
<dt>{{ 'Title'|trans }}</dt>
|
<dt>{{ 'Title'|trans }}</dt>
|
||||||
<dd>{{ document.title }}</dd>
|
<dd>{{ document.title }}</dd>
|
||||||
|
|
||||||
<dt>{{ 'Category'|trans }}</dt>
|
{% if document.category is not null %}
|
||||||
<dd>{{ document.category.name|localize_translatable_string }}</dd>
|
<dt>{{ 'Category'|trans }}</dt>
|
||||||
|
<dd>{{ document.category.name|localize_translatable_string }}</dd>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<dt>{{ 'Description' | trans }}</dt>
|
<dt>{{ 'Description' | trans }}</dt>
|
||||||
<dd>
|
<dd>
|
||||||
|
@ -18,12 +18,12 @@ use function array_key_exists;
|
|||||||
|
|
||||||
final class TranslatableStringHelper implements TranslatableStringHelperInterface
|
final class TranslatableStringHelper implements TranslatableStringHelperInterface
|
||||||
{
|
{
|
||||||
|
private string $defaultLocale;
|
||||||
|
|
||||||
private RequestStack $requestStack;
|
private RequestStack $requestStack;
|
||||||
|
|
||||||
private TranslatorInterface $translator;
|
private TranslatorInterface $translator;
|
||||||
|
|
||||||
private string $defaultLocale;
|
|
||||||
|
|
||||||
public function __construct(RequestStack $requestStack, TranslatorInterface $translator, ParameterBagInterface $parameterBag)
|
public function __construct(RequestStack $requestStack, TranslatorInterface $translator, ParameterBagInterface $parameterBag)
|
||||||
{
|
{
|
||||||
$this->requestStack = $requestStack;
|
$this->requestStack = $requestStack;
|
||||||
|
@ -135,8 +135,6 @@ class AccompanyingPeriod implements
|
|||||||
private ?ClosingMotive $closingMotive = null;
|
private ?ClosingMotive $closingMotive = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Collection
|
|
||||||
*
|
|
||||||
* @ORM\OneToMany(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\Comment",
|
* @ORM\OneToMany(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\Comment",
|
||||||
* mappedBy="accompanyingPeriod",
|
* mappedBy="accompanyingPeriod",
|
||||||
* cascade={"persist", "remove"},
|
* cascade={"persist", "remove"},
|
||||||
@ -147,7 +145,6 @@ class AccompanyingPeriod implements
|
|||||||
private Collection $comments;
|
private Collection $comments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
|
||||||
* @ORM\Column(type="boolean", options={"default": false})
|
* @ORM\Column(type="boolean", options={"default": false})
|
||||||
* @Groups({"read", "write", "docgen:read"})
|
* @Groups({"read", "write", "docgen:read"})
|
||||||
*/
|
*/
|
||||||
@ -167,7 +164,6 @@ class AccompanyingPeriod implements
|
|||||||
private ?User $createdBy = null;
|
private ?User $createdBy = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
|
||||||
* @ORM\Column(type="boolean", options={"default": false})
|
* @ORM\Column(type="boolean", options={"default": false})
|
||||||
* @Groups({"read", "write", "docgen:read"})
|
* @Groups({"read", "write", "docgen:read"})
|
||||||
*/
|
*/
|
||||||
@ -216,8 +212,6 @@ class AccompanyingPeriod implements
|
|||||||
private ?Origin $origin = null;
|
private ?Origin $origin = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Collection
|
|
||||||
*
|
|
||||||
* @ORM\OneToMany(targetEntity=AccompanyingPeriodParticipation::class,
|
* @ORM\OneToMany(targetEntity=AccompanyingPeriodParticipation::class,
|
||||||
* mappedBy="accompanyingPeriod", orphanRemoval=true,
|
* mappedBy="accompanyingPeriod", orphanRemoval=true,
|
||||||
* cascade={"persist", "refresh", "remove", "merge", "detach"})
|
* cascade={"persist", "refresh", "remove", "merge", "detach"})
|
||||||
@ -235,15 +229,12 @@ class AccompanyingPeriod implements
|
|||||||
private ?Person $personLocation = null;
|
private ?Person $personLocation = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
|
||||||
*
|
|
||||||
* @ORM\Column(type="text")
|
* @ORM\Column(type="text")
|
||||||
* @Groups({"read", "write"})
|
* @Groups({"read", "write"})
|
||||||
*/
|
*/
|
||||||
private string $remark = '';
|
private string $remark = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
|
||||||
* @ORM\Column(type="boolean", options={"default": false})
|
* @ORM\Column(type="boolean", options={"default": false})
|
||||||
* @Groups({"read", "write", "docgen:read"})
|
* @Groups({"read", "write", "docgen:read"})
|
||||||
*/
|
*/
|
||||||
@ -262,8 +253,6 @@ class AccompanyingPeriod implements
|
|||||||
private ?ThirdParty $requestorThirdParty = null;
|
private ?ThirdParty $requestorThirdParty = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Collection
|
|
||||||
*
|
|
||||||
* @ORM\OneToMany(
|
* @ORM\OneToMany(
|
||||||
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\Resource",
|
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\Resource",
|
||||||
* mappedBy="accompanyingPeriod",
|
* mappedBy="accompanyingPeriod",
|
||||||
@ -276,7 +265,6 @@ class AccompanyingPeriod implements
|
|||||||
private Collection $resources;
|
private Collection $resources;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Collection
|
|
||||||
* @ORM\ManyToMany(
|
* @ORM\ManyToMany(
|
||||||
* targetEntity=Scope::class,
|
* targetEntity=Scope::class,
|
||||||
* cascade={}
|
* cascade={}
|
||||||
@ -304,7 +292,6 @@ class AccompanyingPeriod implements
|
|||||||
private Collection $socialIssues;
|
private Collection $socialIssues;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
|
||||||
* @ORM\Column(type="string", length=32, nullable=true)
|
* @ORM\Column(type="string", length=32, nullable=true)
|
||||||
* @Groups({"read"})
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
@ -666,7 +653,7 @@ class AccompanyingPeriod implements
|
|||||||
*
|
*
|
||||||
* @return DateTime
|
* @return DateTime
|
||||||
*/
|
*/
|
||||||
public function getOpeningDate(): ?\DateTime
|
public function getOpeningDate(): ?DateTime
|
||||||
{
|
{
|
||||||
return $this->openingDate;
|
return $this->openingDate;
|
||||||
}
|
}
|
||||||
|
@ -39,21 +39,23 @@ class Origin
|
|||||||
* @ORM\Column(type="json")
|
* @ORM\Column(type="json")
|
||||||
* @Groups({"read"})
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private array $label = [];
|
private $label;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="date_immutable", nullable=true)
|
* @ORM\Column(type="date_immutable", nullable=true)
|
||||||
* @Groups({"read"})
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private ?\DateTimeImmutable $noActiveAfter = null;
|
private ?DateTimeImmutable $noActiveAfter = null;
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLabel(): array
|
public function getLabel()
|
||||||
{
|
{
|
||||||
|
dump($this->label);
|
||||||
|
|
||||||
return $this->label;
|
return $this->label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,14 @@
|
|||||||
<?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\Serializer\Normalizer;
|
namespace Chill\PersonBundle\Serializer\Normalizer;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Scope;
|
use Chill\MainBundle\Entity\Scope;
|
||||||
@ -10,42 +19,33 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|||||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||||
use Chill\PersonBundle\Templating\Entity\ClosingMotiveRender;
|
use Chill\PersonBundle\Templating\Entity\ClosingMotiveRender;
|
||||||
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
||||||
use Symfony\Component\Serializer\Exception\CircularReferenceException;
|
use DateTime;
|
||||||
use Symfony\Component\Serializer\Exception\ExceptionInterface;
|
|
||||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
||||||
use Symfony\Component\Serializer\Exception\LogicException;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||||
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
|
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
use function array_key_exists;
|
||||||
|
use function in_array;
|
||||||
|
use function is_array;
|
||||||
|
|
||||||
class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterface, NormalizerAwareInterface
|
class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterface, NormalizerAwareInterface
|
||||||
{
|
{
|
||||||
use NormalizerAwareTrait;
|
use NormalizerAwareTrait;
|
||||||
|
|
||||||
private TranslatorInterface $translator;
|
|
||||||
|
|
||||||
private TranslatableStringHelper $translatableStringHelper;
|
|
||||||
|
|
||||||
private SocialIssueRender $socialIssueRender;
|
|
||||||
|
|
||||||
private ClosingMotiveRender $closingMotiveRender;
|
|
||||||
|
|
||||||
private ScopeResolverDispatcher $scopeResolverDispatcher;
|
|
||||||
|
|
||||||
private const IGNORE_FIRST_PASS_KEY = 'acc_period_ignore_first_pass';
|
private const IGNORE_FIRST_PASS_KEY = 'acc_period_ignore_first_pass';
|
||||||
|
|
||||||
private const PERIOD_NULL = [
|
private const PERIOD_NULL = [
|
||||||
'id' => "",
|
'id' => '',
|
||||||
'closingDate' => \DateTime::class,
|
'closingDate' => DateTime::class,
|
||||||
'confidential' => "",
|
'confidential' => '',
|
||||||
'confidentialText' => '',
|
'confidentialText' => '',
|
||||||
'createdAt' => \DateTime::class,
|
'createdAt' => DateTime::class,
|
||||||
'createdBy' => User::class,
|
'createdBy' => User::class,
|
||||||
'emergency' => "",
|
'emergency' => '',
|
||||||
'emergencyText' => '',
|
'emergencyText' => '',
|
||||||
'openingDate' => \DateTime::class,
|
'openingDate' => DateTime::class,
|
||||||
'originText' => '',
|
'originText' => '',
|
||||||
'requestorAnonymous' => false,
|
'requestorAnonymous' => false,
|
||||||
'socialIssues' => [],
|
'socialIssues' => [],
|
||||||
@ -59,6 +59,16 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
|
|||||||
'participations' => [],
|
'participations' => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
private ClosingMotiveRender $closingMotiveRender;
|
||||||
|
|
||||||
|
private ScopeResolverDispatcher $scopeResolverDispatcher;
|
||||||
|
|
||||||
|
private SocialIssueRender $socialIssueRender;
|
||||||
|
|
||||||
|
private TranslatableStringHelper $translatableStringHelper;
|
||||||
|
|
||||||
|
private TranslatorInterface $translator;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
TranslatorInterface $translator,
|
TranslatorInterface $translator,
|
||||||
TranslatableStringHelper $translatableStringHelper,
|
TranslatableStringHelper $translatableStringHelper,
|
||||||
@ -73,38 +83,19 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
|
|||||||
$this->scopeResolverDispatcher = $scopeResolverDispatcher;
|
$this->scopeResolverDispatcher = $scopeResolverDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function supportsNormalization($data, string $format = null, array $context = []): bool
|
|
||||||
{
|
|
||||||
if ('docgen' !== $format) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($data instanceof AccompanyingPeriod) {
|
|
||||||
if (array_key_exists(self::IGNORE_FIRST_PASS_KEY, $context)
|
|
||||||
&& in_array(spl_object_hash($data), $context[self::IGNORE_FIRST_PASS_KEY])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} elseif (null === $data && ($context['docgen:expects'] ?? null) === AccompanyingPeriod::class) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccompanyingPeriod|null $period
|
* @param AccompanyingPeriod|null $period
|
||||||
*/
|
*/
|
||||||
public function normalize($period, string $format = null, array $context = [])
|
public function normalize($period, ?string $format = null, array $context = [])
|
||||||
{
|
{
|
||||||
if ($period instanceof AccompanyingPeriod) {
|
if ($period instanceof AccompanyingPeriod) {
|
||||||
$ignored = $context[self::IGNORE_FIRST_PASS_KEY] ?? [];
|
$ignored = $context[self::IGNORE_FIRST_PASS_KEY] ?? [];
|
||||||
$ignored[] = spl_object_hash($period);
|
$ignored[] = spl_object_hash($period);
|
||||||
$initial =
|
$initial =
|
||||||
$this->normalizer->normalize($period, $format, \array_merge($context,
|
$this->normalizer->normalize($period, $format, array_merge(
|
||||||
[self::IGNORE_FIRST_PASS_KEY => $ignored, AbstractNormalizer::GROUPS => 'docgen:read']));
|
$context,
|
||||||
|
[self::IGNORE_FIRST_PASS_KEY => $ignored, AbstractNormalizer::GROUPS => 'docgen:read']
|
||||||
|
));
|
||||||
|
|
||||||
// some transformation
|
// some transformation
|
||||||
$user = $initial['user'];
|
$user = $initial['user'];
|
||||||
@ -122,14 +113,14 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
|
|||||||
// and add data custom
|
// and add data custom
|
||||||
[
|
[
|
||||||
'intensity' => $this->translator->trans($period->getIntensity()),
|
'intensity' => $this->translator->trans($period->getIntensity()),
|
||||||
'step' => $this->translator->trans('accompanying_period.'.$period->getStep()),
|
'step' => $this->translator->trans('accompanying_period.' . $period->getStep()),
|
||||||
'emergencyText' => $period->isEmergency() ? $this->translator->trans('accompanying_period.emergency') : '',
|
'emergencyText' => $period->isEmergency() ? $this->translator->trans('accompanying_period.emergency') : '',
|
||||||
'confidentialText' => $period->isConfidential() ? $this->translator->trans('confidential') : '',
|
'confidentialText' => $period->isConfidential() ? $this->translator->trans('confidential') : '',
|
||||||
'originText' => null !== $period->getOrigin() ? $this->translatableStringHelper->localize($period->getOrigin()->getLabel()) : '',
|
//'originText' => null !== $period->getOrigin() ? $this->translatableStringHelper->localize($period->getOrigin()->getLabel()) : '',
|
||||||
'closingMotiveText' => null !== $period->getClosingMotive() ?
|
'closingMotiveText' => null !== $period->getClosingMotive() ?
|
||||||
$this->closingMotiveRender->renderString($period->getClosingMotive(), []) : '',
|
$this->closingMotiveRender->renderString($period->getClosingMotive(), []) : '',
|
||||||
'ref' => $user,
|
'ref' => $user,
|
||||||
'socialIssuesText' => implode(', ', array_map(function(SocialIssue $s) {
|
'socialIssuesText' => implode(', ', array_map(function (SocialIssue $s) {
|
||||||
return $this->socialIssueRender->renderString($s, []);
|
return $this->socialIssueRender->renderString($s, []);
|
||||||
}, $period->getSocialIssues()->toArray())),
|
}, $period->getSocialIssues()->toArray())),
|
||||||
'scopesText' => implode(', ', array_map(function (Scope $s) {
|
'scopesText' => implode(', ', array_map(function (Scope $s) {
|
||||||
@ -142,6 +133,28 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
|
|||||||
return self::PERIOD_NULL;
|
return self::PERIOD_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new InvalidArgumentException("this neither an accompanying period or null");
|
throw new InvalidArgumentException('this neither an accompanying period or null');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
|
||||||
|
{
|
||||||
|
if ('docgen' !== $format) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($data instanceof AccompanyingPeriod) {
|
||||||
|
if (array_key_exists(self::IGNORE_FIRST_PASS_KEY, $context)
|
||||||
|
&& in_array(spl_object_hash($data), $context[self::IGNORE_FIRST_PASS_KEY], true)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === $data && AccompanyingPeriod::class === ($context['docgen:expects'] ?? null)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,32 @@ namespace Chill\PersonBundle\Service\DocGenerator;
|
|||||||
|
|
||||||
use Chill\DocGeneratorBundle\Context\DocGeneratorContextInterface;
|
use Chill\DocGeneratorBundle\Context\DocGeneratorContextInterface;
|
||||||
use Chill\DocGeneratorBundle\Context\Exception\UnexpectedTypeException;
|
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 Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
use DateTime;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||||
|
|
||||||
class AccompanyingPeriodContext implements DocGeneratorContextInterface
|
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
|
public function getData($entity): array
|
||||||
{
|
{
|
||||||
@ -49,6 +69,20 @@ class AccompanyingPeriodContext implements DocGeneratorContextInterface
|
|||||||
return false;
|
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
|
public function supports(string $entityClass): bool
|
||||||
{
|
{
|
||||||
return AccompanyingPeriod::class === $entityClass;
|
return AccompanyingPeriod::class === $entityClass;
|
||||||
|
@ -1,15 +1,27 @@
|
|||||||
<?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 Serializer\Normalizer;
|
namespace Serializer\Normalizer;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Scope;
|
use Chill\MainBundle\Entity\Scope;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
|
||||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||||
|
|
||||||
class AccompanyingPeriodDocGenNormalizerTest extends KernelTestCase
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class AccompanyingPeriodDocGenNormalizerTest extends KernelTestCase
|
||||||
{
|
{
|
||||||
private NormalizerInterface $normalizer;
|
private NormalizerInterface $normalizer;
|
||||||
|
|
||||||
@ -27,7 +39,7 @@ class AccompanyingPeriodDocGenNormalizerTest extends KernelTestCase
|
|||||||
$period->setOrigin((new AccompanyingPeriod\Origin())->setLabel(['fr' => 'origin']));
|
$period->setOrigin((new AccompanyingPeriod\Origin())->setLabel(['fr' => 'origin']));
|
||||||
$period->setClosingMotive((new AccompanyingPeriod\ClosingMotive())->setName(['closing']));
|
$period->setClosingMotive((new AccompanyingPeriod\ClosingMotive())->setName(['closing']));
|
||||||
$period->addScope((new Scope())->setName(['fr' => 'scope1']));
|
$period->addScope((new Scope())->setName(['fr' => 'scope1']));
|
||||||
$period->addScope((new Scope())->setName(['fr' =>'scope2']));
|
$period->addScope((new Scope())->setName(['fr' => 'scope2']));
|
||||||
$period->addSocialIssue((new SocialIssue())->setTitle(['fr' => 'issue1']));
|
$period->addSocialIssue((new SocialIssue())->setTitle(['fr' => 'issue1']));
|
||||||
$period->addSocialIssue((new SocialIssue())->setTitle(['fr' => 'issue2']));
|
$period->addSocialIssue((new SocialIssue())->setTitle(['fr' => 'issue2']));
|
||||||
$data = $this->normalizer->normalize($period, 'docgen', ['docgen:expects' => AccompanyingPeriod::class]);
|
$data = $this->normalizer->normalize($period, 'docgen', ['docgen:expects' => AccompanyingPeriod::class]);
|
||||||
@ -59,7 +71,7 @@ class AccompanyingPeriodDocGenNormalizerTest extends KernelTestCase
|
|||||||
$this->assertEqualsCanonicalizing(array_keys($expected), array_keys($data));
|
$this->assertEqualsCanonicalizing(array_keys($expected), array_keys($data));
|
||||||
|
|
||||||
foreach ($expected as $key => $item) {
|
foreach ($expected as $key => $item) {
|
||||||
if ($item === '@ignored') {
|
if ('@ignored' === $item) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,13 +84,13 @@ class AccompanyingPeriodDocGenNormalizerTest extends KernelTestCase
|
|||||||
$data = $this->normalizer->normalize(null, 'docgen', ['docgen:expects' => AccompanyingPeriod::class]);
|
$data = $this->normalizer->normalize(null, 'docgen', ['docgen:expects' => AccompanyingPeriod::class]);
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'id' => "",
|
'id' => '',
|
||||||
'closingDate' => '@ignored',
|
'closingDate' => '@ignored',
|
||||||
'confidential' => "",
|
'confidential' => '',
|
||||||
'confidentialText' => '',
|
'confidentialText' => '',
|
||||||
'createdAt' => '@ignored',
|
'createdAt' => '@ignored',
|
||||||
'createdBy' => '@ignored',
|
'createdBy' => '@ignored',
|
||||||
'emergency' => "",
|
'emergency' => '',
|
||||||
'emergencyText' => '',
|
'emergencyText' => '',
|
||||||
'openingDate' => '@ignored',
|
'openingDate' => '@ignored',
|
||||||
'originText' => '',
|
'originText' => '',
|
||||||
@ -98,12 +110,11 @@ class AccompanyingPeriodDocGenNormalizerTest extends KernelTestCase
|
|||||||
$this->assertEqualsCanonicalizing(array_keys($expected), array_keys($data));
|
$this->assertEqualsCanonicalizing(array_keys($expected), array_keys($data));
|
||||||
|
|
||||||
foreach ($expected as $key => $item) {
|
foreach ($expected as $key => $item) {
|
||||||
if ($item === '@ignored') {
|
if ('@ignored' === $item) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertEquals($item, $data[$key]);
|
$this->assertEquals($item, $data[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user