mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -14,8 +14,6 @@ namespace Chill\PersonBundle\Service\AccompanyingPeriod;
|
||||
use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@@ -24,54 +22,54 @@ class OldDraftAccompanyingPeriodRemover implements OldDraftAccompanyingPeriodRem
|
||||
{
|
||||
public function __construct(private readonly EntityManagerInterface $em, private readonly LoggerInterface $logger) {}
|
||||
|
||||
public function remove(DateInterval $interval): void
|
||||
public function remove(\DateInterval $interval): void
|
||||
{
|
||||
$this->logger->debug('[' . self::class . '] start to remove old periods', [
|
||||
$this->logger->debug('['.self::class.'] start to remove old periods', [
|
||||
'interval' => $interval->format('%d days'),
|
||||
]);
|
||||
|
||||
$beforeDate = (new DateTimeImmutable('now'))->sub($interval);
|
||||
$beforeDate = (new \DateTimeImmutable('now'))->sub($interval);
|
||||
|
||||
$results = $this->em->wrapInTransaction(static function (EntityManagerInterface $em) use ($beforeDate) {
|
||||
$subDQL = 'SELECT p FROM ' . AccompanyingPeriod::class . ' p WHERE p.createdAt < :beforeDate AND p.step = :draft';
|
||||
$subDQL = 'SELECT p FROM '.AccompanyingPeriod::class.' p WHERE p.createdAt < :beforeDate AND p.step = :draft';
|
||||
$parameters = [
|
||||
'beforeDate' => $beforeDate,
|
||||
'draft' => AccompanyingPeriod::STEP_DRAFT,
|
||||
];
|
||||
|
||||
$resources = $em->createQuery(
|
||||
'DELETE ' . AccompanyingPeriod\Resource::class . " r WHERE r.accompanyingPeriod IN ({$subDQL})"
|
||||
'DELETE '.AccompanyingPeriod\Resource::class." r WHERE r.accompanyingPeriod IN ({$subDQL})"
|
||||
)
|
||||
->setParameters($parameters)
|
||||
->getSingleScalarResult();
|
||||
|
||||
$participations = $em->createQuery(
|
||||
'DELETE ' . AccompanyingPeriodParticipation::class . " part WHERE part.accompanyingPeriod IN ({$subDQL})"
|
||||
'DELETE '.AccompanyingPeriodParticipation::class." part WHERE part.accompanyingPeriod IN ({$subDQL})"
|
||||
)
|
||||
->setParameters($parameters)
|
||||
->getSingleScalarResult();
|
||||
|
||||
$userHistory = $em->createQuery(
|
||||
'DELETE ' . AccompanyingPeriod\UserHistory::class . " h WHERE h.accompanyingPeriod IN ({$subDQL})"
|
||||
'DELETE '.AccompanyingPeriod\UserHistory::class." h WHERE h.accompanyingPeriod IN ({$subDQL})"
|
||||
)
|
||||
->setParameters($parameters)
|
||||
->getSingleScalarResult();
|
||||
|
||||
$comments = $em->createQuery(
|
||||
'DELETE ' . AccompanyingPeriod\Comment::class . " c WHERE c.accompanyingPeriod IN ({$subDQL})"
|
||||
'DELETE '.AccompanyingPeriod\Comment::class." c WHERE c.accompanyingPeriod IN ({$subDQL})"
|
||||
)
|
||||
->setParameters($parameters)
|
||||
->getSingleScalarResult();
|
||||
|
||||
$documents = $em->createQuery(
|
||||
'DELETE ' . AccompanyingCourseDocument::class . " d WHERE d.course IN ({$subDQL})"
|
||||
'DELETE '.AccompanyingCourseDocument::class." d WHERE d.course IN ({$subDQL})"
|
||||
)
|
||||
->setParameters($parameters)
|
||||
->getSingleScalarResult();
|
||||
|
||||
$periods = $em
|
||||
->createQuery(
|
||||
'DELETE ' . AccompanyingPeriod::class . ' p WHERE p.createdAt < :beforeDate
|
||||
'DELETE '.AccompanyingPeriod::class.' p WHERE p.createdAt < :beforeDate
|
||||
AND p.step = :draft'
|
||||
)
|
||||
->setParameter(':beforeDate', $beforeDate, Types::DATETIME_IMMUTABLE)
|
||||
@@ -88,7 +86,7 @@ class OldDraftAccompanyingPeriodRemover implements OldDraftAccompanyingPeriodRem
|
||||
];
|
||||
});
|
||||
|
||||
$this->logger->info('[' . self::class . '] periods removed', array_merge($results, [
|
||||
$this->logger->info('['.self::class.'] periods removed', array_merge($results, [
|
||||
'interval' => $interval->format('%d days'),
|
||||
]));
|
||||
}
|
||||
|
@@ -11,9 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Service\AccompanyingPeriod;
|
||||
|
||||
use DateInterval;
|
||||
|
||||
interface OldDraftAccompanyingPeriodRemoverInterface
|
||||
{
|
||||
public function remove(DateInterval $interval): void;
|
||||
public function remove(\DateInterval $interval): void;
|
||||
}
|
||||
|
@@ -30,7 +30,6 @@ use Chill\PersonBundle\Templating\Entity\PersonRenderInterface;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
|
||||
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
|
||||
use DateTime;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
@@ -41,10 +40,9 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
use function array_key_exists;
|
||||
|
||||
/**
|
||||
* @see AccompanyingPeriodContextTest
|
||||
*
|
||||
* @template-implements DocGeneratorContextWithPublicFormInterface<AccompanyingPeriod>
|
||||
*/
|
||||
class AccompanyingPeriodContext implements
|
||||
@@ -66,7 +64,7 @@ class AccompanyingPeriodContext implements
|
||||
|
||||
public function adminFormReverseTransform(array $data): array
|
||||
{
|
||||
if (array_key_exists('category', $data)) {
|
||||
if (\array_key_exists('category', $data)) {
|
||||
$data['category'] = [
|
||||
'idInsideBundle' => $data['category']->getIdInsideBundle(),
|
||||
'bundleId' => $data['category']->getBundleId(),
|
||||
@@ -89,7 +87,7 @@ class AccompanyingPeriodContext implements
|
||||
'thirdPartyLabel' => $data['thirdPartyLabel'] ?? $this->translator->trans('Third party'),
|
||||
];
|
||||
|
||||
if (array_key_exists('category', $data)) {
|
||||
if (\array_key_exists('category', $data)) {
|
||||
$r['category'] = $this->documentCategoryRepository->find($data['category']);
|
||||
}
|
||||
|
||||
@@ -176,7 +174,7 @@ class AccompanyingPeriodContext implements
|
||||
'multiple' => false,
|
||||
'expanded' => true,
|
||||
'required' => false,
|
||||
'label' => $options[$key . 'Label'],
|
||||
'label' => $options[$key.'Label'],
|
||||
'placeholder' => $this->translator->trans('Any person selected'),
|
||||
]);
|
||||
}
|
||||
@@ -231,7 +229,7 @@ class AccompanyingPeriodContext implements
|
||||
if ($options['thirdParty']) {
|
||||
$data['thirdParty'] = $this->normalizer->normalize($contextGenerationData['thirdParty'], 'docgen', [
|
||||
'docgen:expects' => ThirdParty::class,
|
||||
'groups' => 'docgen:read'
|
||||
'groups' => 'docgen:read',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -274,7 +272,7 @@ class AccompanyingPeriodContext implements
|
||||
{
|
||||
$options = $template->getOptions();
|
||||
|
||||
return $options['mainPerson'] || $options['person1'] || $options['person2'] || $options ['thirdParty'];
|
||||
return $options['mainPerson'] || $options['person1'] || $options['person2'] || $options['thirdParty'];
|
||||
}
|
||||
|
||||
public function contextGenerationDataNormalize(DocGeneratorTemplate $template, $entity, array $data): array
|
||||
@@ -315,12 +313,12 @@ class AccompanyingPeriodContext implements
|
||||
$doc = new AccompanyingCourseDocument();
|
||||
$doc->setTemplate($template)
|
||||
->setTitle($this->translatableStringHelper->localize($template->getName()))
|
||||
->setDate(new DateTime())
|
||||
->setDate(new \DateTime())
|
||||
->setDescription($this->translatableStringHelper->localize($template->getName()))
|
||||
->setCourse($entity)
|
||||
->setObject($storedObject);
|
||||
|
||||
if (array_key_exists('category', $template->getOptions())) {
|
||||
if (\array_key_exists('category', $template->getOptions())) {
|
||||
$doc
|
||||
->setCategory(
|
||||
$this->documentCategoryRepository->find(
|
||||
|
@@ -20,10 +20,10 @@ use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
/**
|
||||
* Generate a context for an @link{AccompanyingPeriodWork}.
|
||||
* Generate a context for an @see{AccompanyingPeriodWork}.
|
||||
*
|
||||
* Although there isn't any document associated to AccompanyingPeriodWork, this context
|
||||
* is use by @link{AccompanyingPeriodWorkEvaluationContext}.
|
||||
* is use by @see{AccompanyingPeriodWorkEvaluationContext}.
|
||||
*
|
||||
* @implements DocGeneratorContextWithPublicFormInterface<AccompanyingPeriodWork>
|
||||
*/
|
||||
|
@@ -23,7 +23,6 @@ use Chill\PersonBundle\Entity\SocialWork\Evaluation;
|
||||
use Chill\PersonBundle\Repository\SocialWork\EvaluationRepository;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
|
||||
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@@ -124,6 +123,7 @@ class AccompanyingPeriodWorkEvaluationContext implements
|
||||
AbstractNormalizer::GROUPS => ['docgen:read'],
|
||||
]
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Service\DocGenerator;
|
||||
|
||||
use Chill\DocGeneratorBundle\Context\Exception\UnexpectedTypeException;
|
||||
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
use Chill\DocGeneratorBundle\Service\Context\BaseContextData;
|
||||
use Chill\DocStoreBundle\Entity\DocumentCategory;
|
||||
@@ -29,15 +28,12 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Entity\Person\PersonResource;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\Person\ResidentialAddress;
|
||||
use Chill\PersonBundle\Repository\PersonRepository;
|
||||
use Chill\PersonBundle\Repository\ResidentialAddressRepository;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
|
||||
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use LogicException;
|
||||
use Service\DocGenerator\PersonContextTest;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
@@ -46,10 +42,7 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function array_key_exists;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* @see PersonContextTest
|
||||
@@ -79,7 +72,7 @@ final class PersonContext implements PersonContextInterface
|
||||
|
||||
public function adminFormReverseTransform(array $data): array
|
||||
{
|
||||
if (array_key_exists('category', $data)) {
|
||||
if (\array_key_exists('category', $data)) {
|
||||
$data['category'] = [
|
||||
'idInsideBundle' => $data['category']->getIdInsideBundle(),
|
||||
'bundleId' => $data['category']->getBundleId(),
|
||||
@@ -98,7 +91,7 @@ final class PersonContext implements PersonContextInterface
|
||||
'thirdPartyLabel' => $data['thirdPartyLabel'] ?? $this->translator->trans('Third party'),
|
||||
];
|
||||
|
||||
if (array_key_exists('category', $data)) {
|
||||
if (\array_key_exists('category', $data)) {
|
||||
$r['category'] = $this->documentCategoryRepository->find($data['category']);
|
||||
}
|
||||
|
||||
@@ -197,7 +190,7 @@ final class PersonContext implements PersonContextInterface
|
||||
if ($template->getOptions()['thirdParty']) {
|
||||
$data['thirdParty'] = $this->normalizer->normalize($contextGenerationData['thirdParty'], 'docgen', [
|
||||
'docgen:expects' => ThirdParty::class,
|
||||
'groups' => 'docgen:read'
|
||||
'groups' => 'docgen:read',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -285,12 +278,12 @@ final class PersonContext implements PersonContextInterface
|
||||
->setTitle(
|
||||
$contextGenerationData['title'] ?? $this->translatableStringHelper->localize($template->getName())
|
||||
)
|
||||
->setDate(new DateTime())
|
||||
->setDate(new \DateTime())
|
||||
->setDescription($this->translatableStringHelper->localize($template->getName()))
|
||||
->setPerson($entity)
|
||||
->setObject($storedObject);
|
||||
|
||||
if (array_key_exists('category', $template->getOptions())) {
|
||||
if (\array_key_exists('category', $template->getOptions())) {
|
||||
$doc
|
||||
->setCategory(
|
||||
$this->documentCategoryRepository->find(
|
||||
@@ -309,8 +302,8 @@ final class PersonContext implements PersonContextInterface
|
||||
$this->centerResolverManager->resolveCenters($entity)
|
||||
);
|
||||
|
||||
if (1 !== count($scopes)) {
|
||||
throw new LogicException('at this step, it should have only one scope');
|
||||
if (1 !== \count($scopes)) {
|
||||
throw new \LogicException('at this step, it should have only one scope');
|
||||
}
|
||||
|
||||
$doc->setScope($scopes[0]);
|
||||
@@ -321,7 +314,7 @@ final class PersonContext implements PersonContextInterface
|
||||
|
||||
private function isScopeNecessary(Person $person): bool
|
||||
{
|
||||
if ($this->showScopes && 1 < count(
|
||||
if ($this->showScopes && 1 < \count(
|
||||
$this->authorizationHelper->getReachableScopes(
|
||||
$this->security->getUser(),
|
||||
PersonDocumentVoter::CREATE,
|
||||
|
@@ -12,7 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Service\EntityInfo;
|
||||
|
||||
/**
|
||||
* Build a list of different Query parts into a single query
|
||||
* Build a list of different Query parts into a single query.
|
||||
*/
|
||||
class AccompanyingPeriodInfoQueryBuilder
|
||||
{
|
||||
|
@@ -11,7 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Service\EntityInfo\AccompanyingPeriodInfoQueryPart;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
use Chill\PersonBundle\Service\EntityInfo\AccompanyingPeriodInfoUnionQueryPartInterface;
|
||||
|
||||
|
@@ -11,7 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Service\EntityInfo\AccompanyingPeriodInfoQueryPart;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
use Chill\PersonBundle\Service\EntityInfo\AccompanyingPeriodInfoUnionQueryPartInterface;
|
||||
|
||||
|
@@ -11,7 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Service\EntityInfo\AccompanyingPeriodInfoQueryPart;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
use Chill\PersonBundle\Service\EntityInfo\AccompanyingPeriodInfoUnionQueryPartInterface;
|
||||
|
||||
|
@@ -11,7 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Service\EntityInfo\AccompanyingPeriodInfoQueryPart;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
use Chill\PersonBundle\Service\EntityInfo\AccompanyingPeriodInfoUnionQueryPartInterface;
|
||||
|
||||
|
@@ -11,8 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Service\EntityInfo\AccompanyingPeriodInfoQueryPart;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
|
||||
use Chill\PersonBundle\Service\EntityInfo\AccompanyingPeriodInfoUnionQueryPartInterface;
|
||||
|
||||
|
@@ -19,7 +19,6 @@ use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkVoter;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
@@ -33,7 +32,7 @@ final readonly class AccompanyingPeriodWorkEvaluationGenericDocProvider implemen
|
||||
private EntityManagerInterface $entityManager,
|
||||
) {}
|
||||
|
||||
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
|
||||
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
|
||||
{
|
||||
$accompanyingPeriodWorkMetadata = $this->entityManager->getClassMetadata(AccompanyingPeriod\AccompanyingPeriodWork::class);
|
||||
$query = $this->buildBaseQuery();
|
||||
@@ -52,7 +51,7 @@ final readonly class AccompanyingPeriodWorkEvaluationGenericDocProvider implemen
|
||||
return $this->security->isGranted(AccompanyingPeriodWorkVoter::SEE, $accompanyingPeriod);
|
||||
}
|
||||
|
||||
private function addWhereClausesToQuery(FetchQuery $query, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery
|
||||
private function addWhereClausesToQuery(FetchQuery $query, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQuery
|
||||
{
|
||||
$classMetadata = $this->entityManager->getClassMetadata(AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument::class);
|
||||
$storedObjectMetadata = $this->entityManager->getClassMetadata(StoredObject::class);
|
||||
@@ -76,7 +75,7 @@ final readonly class AccompanyingPeriodWorkEvaluationGenericDocProvider implemen
|
||||
if (null !== $content) {
|
||||
$query->addWhereClause(
|
||||
sprintf('apwed.%s ilike ?', $classMetadata->getColumnName('title')),
|
||||
['%' . $content . '%'],
|
||||
['%'.$content.'%'],
|
||||
[Types::STRING]
|
||||
);
|
||||
}
|
||||
@@ -84,7 +83,7 @@ final readonly class AccompanyingPeriodWorkEvaluationGenericDocProvider implemen
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
|
||||
public function buildFetchQueryForPerson(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
|
||||
{
|
||||
$storedObjectMetadata = $this->entityManager->getClassMetadata(StoredObject::class);
|
||||
$accompanyingPeriodWorkMetadata = $this->entityManager->getClassMetadata(AccompanyingPeriod\AccompanyingPeriodWork::class);
|
||||
@@ -105,8 +104,8 @@ final readonly class AccompanyingPeriodWorkEvaluationGenericDocProvider implemen
|
||||
$storedObjectMetadata->getColumnName('createdAt')
|
||||
);
|
||||
$orParams = [...$orParams, $participation->getAccompanyingPeriod()->getId(),
|
||||
DateTimeImmutable::createFromInterface($participation->getStartDate()),
|
||||
null === $participation->getEndDate() ? null : DateTimeImmutable::createFromInterface($participation->getEndDate())];
|
||||
\DateTimeImmutable::createFromInterface($participation->getStartDate()),
|
||||
null === $participation->getEndDate() ? null : \DateTimeImmutable::createFromInterface($participation->getEndDate())];
|
||||
$orTypes = [...$orTypes, Types::INTEGER, Types::DATE_IMMUTABLE, Types::DATE_IMMUTABLE];
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,6 @@ namespace Chill\PersonBundle\Service\GenericDoc\Renderer;
|
||||
|
||||
use Chill\DocStoreBundle\GenericDoc\GenericDocDTO;
|
||||
use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocumentRepository;
|
||||
use Chill\PersonBundle\Service\GenericDoc\Providers\AccompanyingPeriodWorkEvaluationGenericDocProvider;
|
||||
|
||||
@@ -25,7 +24,7 @@ final readonly class AccompanyingPeriodWorkEvaluationGenericDocRenderer implemen
|
||||
|
||||
public function supports(GenericDocDTO $genericDocDTO, $options = []): bool
|
||||
{
|
||||
return $genericDocDTO->key === AccompanyingPeriodWorkEvaluationGenericDocProvider::KEY;
|
||||
return AccompanyingPeriodWorkEvaluationGenericDocProvider::KEY === $genericDocDTO->key;
|
||||
}
|
||||
|
||||
public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string
|
||||
|
@@ -24,16 +24,13 @@ use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Query\Expr\Comparison;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use Exception;
|
||||
|
||||
use function count;
|
||||
|
||||
final readonly class SocialWorkMetadata implements SocialWorkMetadataInterface
|
||||
{
|
||||
public function __construct(private SocialIssueRepository $socialIssueRepository, private SocialActionRepository $socialActionRepository, private GoalRepository $goalRepository, private ResultRepository $resultRepository, private EvaluationRepository $evaluationRepository, private EntityManagerInterface $entityManager) {}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function import(iterable $dataset): bool
|
||||
{
|
||||
@@ -130,9 +127,9 @@ final readonly class SocialWorkMetadata implements SocialWorkMetadataInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*
|
||||
* @return object
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function getOrCreateEntity(ObjectRepository $repository, string $field, array $jsonCriterias = [])
|
||||
{
|
||||
@@ -149,13 +146,11 @@ final readonly class SocialWorkMetadata implements SocialWorkMetadataInterface
|
||||
return new $entity();
|
||||
}
|
||||
|
||||
if (count($results) === 1) {
|
||||
if (1 === \count($results)) {
|
||||
return reset($results);
|
||||
}
|
||||
|
||||
throw new Exception(
|
||||
'Unable to create entity.'
|
||||
);
|
||||
throw new \Exception('Unable to create entity.');
|
||||
}
|
||||
|
||||
private function handleEvaluation(?string $evaluationTitle, SocialAction $socialAction): ?Evaluation
|
||||
@@ -220,9 +215,9 @@ final readonly class SocialWorkMetadata implements SocialWorkMetadataInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*
|
||||
* @return array<string, SocialAction|null>
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function handleSocialAction(
|
||||
?string $socialActionTitle,
|
||||
@@ -270,9 +265,9 @@ final readonly class SocialWorkMetadata implements SocialWorkMetadataInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*
|
||||
* @return array<string, SocialIssue|null>
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function handleSocialIssue(
|
||||
?string $socialIssueTitle,
|
||||
@@ -326,12 +321,12 @@ final readonly class SocialWorkMetadata implements SocialWorkMetadataInterface
|
||||
* Index 5: Result
|
||||
* Index 6: Evaluation
|
||||
*
|
||||
* @param array<int, ?string> $row
|
||||
* @param array<string, array<string, <|array|null>|SocialIssue|string, SocialAction|null>|Evaluation|Goal|Result> $previousRow
|
||||
* @param array<int, ?string> $row
|
||||
* @param array{socialIssues: array<SocialIssue>, socialActions: array<SocialAction>, goal: Goal|null, result: Result|null, eval: Evaluation|null} $previousRow
|
||||
*
|
||||
* @throws Exception
|
||||
* @return array{socialIssues: array<SocialIssue>, socialActions: array<SocialAction>, goal: Goal|null, result: Result|null, eval: Evaluation|null}
|
||||
*
|
||||
* @return array<string, array<string, <|array|null>|SocialIssue|string, SocialAction|null>|Evaluation|Goal|Result>
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function import1(int $key, array $row, array $previousRow): array
|
||||
{
|
||||
@@ -350,7 +345,7 @@ final readonly class SocialWorkMetadata implements SocialWorkMetadataInterface
|
||||
$socialIssue = $socialIssues['socialIssueChild'] ?? $socialIssues['socialIssue'];
|
||||
|
||||
if (null === $socialIssue) {
|
||||
throw new Exception(sprintf("no social issue on row {$key}, values: %s", implode(', ', $row)));
|
||||
throw new \Exception(sprintf("no social issue on row {$key}, values: %s", implode(', ', $row)));
|
||||
}
|
||||
|
||||
$socialActions = $this
|
||||
|
Reference in New Issue
Block a user