mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-11-11 22:58:26 +00:00
apply rector rules
This commit is contained in:
@@ -67,15 +67,13 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
|||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choices' => array_combine($this->fields, $this->fields),
|
'choices' => array_combine($this->fields, $this->fields),
|
||||||
'label' => 'Fields to include in export',
|
'label' => 'Fields to include in export',
|
||||||
'constraints' => [new Callback([
|
'constraints' => [new Callback(callback: static function ($selected, ExecutionContextInterface $context) {
|
||||||
'callback' => static function ($selected, ExecutionContextInterface $context) {
|
if (0 === \count($selected)) {
|
||||||
if (0 === \count($selected)) {
|
$context->buildViolation('You must select at least one element')
|
||||||
$context->buildViolation('You must select at least one element')
|
->atPath('fields')
|
||||||
->atPath('fields')
|
->addViolation();
|
||||||
->addViolation();
|
}
|
||||||
}
|
})],
|
||||||
},
|
|
||||||
])],
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
|||||||
* @method ActivityReasonCategory|null findOneBy(array $criteria, array $orderBy = null)
|
* @method ActivityReasonCategory|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
* @method ActivityReasonCategory[] findAll()
|
* @method ActivityReasonCategory[] findAll()
|
||||||
* @method ActivityReasonCategory[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
* @method ActivityReasonCategory[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\ActivityBundle\Entity\ActivityReasonCategory>
|
||||||
*/
|
*/
|
||||||
class ActivityReasonCategoryRepository extends ServiceEntityRepository
|
class ActivityReasonCategoryRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ use Symfony\Component\HttpFoundation\RequestStack;
|
|||||||
* @method ActivityReason|null find($id, $lockMode = null, $lockVersion = null)
|
* @method ActivityReason|null find($id, $lockMode = null, $lockVersion = null)
|
||||||
* @method ActivityReason|null findOneBy(array $criteria, array $orderBy = null)
|
* @method ActivityReason|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
* @method ActivityReason[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
* @method ActivityReason[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\ActivityBundle\Entity\ActivityReason>
|
||||||
*/
|
*/
|
||||||
class ActivityReasonRepository extends ServiceEntityRepository
|
class ActivityReasonRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
|||||||
* @method Activity|null findOneBy(array $criteria, array $orderBy = null)
|
* @method Activity|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
* @method Activity[] findAll()
|
* @method Activity[] findAll()
|
||||||
* @method Activity[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
* @method Activity[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\ActivityBundle\Entity\Activity>
|
||||||
*/
|
*/
|
||||||
class ActivityRepository extends ServiceEntityRepository implements AssociatedEntityToStoredObjectInterface
|
class ActivityRepository extends ServiceEntityRepository implements AssociatedEntityToStoredObjectInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
|||||||
* @method ActivityTypeCategory|null findOneBy(array $criteria, array $orderBy = null)
|
* @method ActivityTypeCategory|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
* @method ActivityTypeCategory[] findAll()
|
* @method ActivityTypeCategory[] findAll()
|
||||||
* @method ActivityTypeCategory[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
* @method ActivityTypeCategory[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\ActivityBundle\Entity\ActivityTypeCategory>
|
||||||
*/
|
*/
|
||||||
class ActivityTypeCategoryRepository extends ServiceEntityRepository
|
class ActivityTypeCategoryRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
|||||||
* @method AsideActivity|null findOneBy(array $criteria, array $orderBy = null)
|
* @method AsideActivity|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
* @method AsideActivity[] findAll()
|
* @method AsideActivity[] findAll()
|
||||||
* @method AsideActivity[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
* @method AsideActivity[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\AsideActivityBundle\Entity\AsideActivity>
|
||||||
*/
|
*/
|
||||||
final class AsideActivityRepository extends ServiceEntityRepository
|
final class AsideActivityRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
|||||||
*
|
*
|
||||||
* This class was generated by the Doctrine ORM. Add your own custom
|
* This class was generated by the Doctrine ORM. Add your own custom
|
||||||
* repository methods below.
|
* repository methods below.
|
||||||
|
*
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\BudgetBundle\Entity\Charge>
|
||||||
*/
|
*/
|
||||||
class ChargeRepository extends ServiceEntityRepository
|
class ChargeRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
@@ -59,10 +61,7 @@ class ChargeRepository extends ServiceEntityRepository
|
|||||||
$qb->orderBy($sort);
|
$qb->orderBy($sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->setParameters([
|
$qb->setParameters(new \Doctrine\Common\Collections\ArrayCollection([new \Doctrine\ORM\Query\Parameter('entity', $entity), new \Doctrine\ORM\Query\Parameter('date', $date)]));
|
||||||
'entity' => $entity,
|
|
||||||
'date' => $date,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $qb->getQuery()->getResult();
|
return $qb->getQuery()->getResult();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
|||||||
*
|
*
|
||||||
* This class was generated by the Doctrine ORM. Add your own custom
|
* This class was generated by the Doctrine ORM. Add your own custom
|
||||||
* repository methods below.
|
* repository methods below.
|
||||||
|
*
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\BudgetBundle\Entity\Resource>
|
||||||
*/
|
*/
|
||||||
class ResourceRepository extends ServiceEntityRepository
|
class ResourceRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
@@ -59,10 +61,7 @@ class ResourceRepository extends ServiceEntityRepository
|
|||||||
$qb->orderBy($sort);
|
$qb->orderBy($sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->setParameters([
|
$qb->setParameters(new \Doctrine\Common\Collections\ArrayCollection([new \Doctrine\ORM\Query\Parameter('entity', $entity), new \Doctrine\ORM\Query\Parameter('date', $date)]));
|
||||||
'entity' => $entity,
|
|
||||||
'date' => $date,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $qb->getQuery()->getResult();
|
return $qb->getQuery()->getResult();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class BudgetElementVoter extends Voter implements ProvideRoleHierarchyInterface
|
|||||||
return $this->voter->supports($attribute, $subject);
|
return $this->voter->supports($attribute, $subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
|
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
$subject instanceof Person
|
$subject instanceof Person
|
||||||
|
|||||||
@@ -26,14 +26,13 @@ use Chill\MainBundle\Repository\UserRepositoryInterface;
|
|||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
#[\Symfony\Component\Console\Attribute\AsCommand(name:'chill:calendar:msgraph-user-map-subscribe')]
|
#[\Symfony\Component\Console\Attribute\AsCommand(name:'chill:calendar:msgraph-user-map-subscribe')]
|
||||||
final class MapAndSubscribeUserCalendarCommand extends Command
|
final class MapAndSubscribeUserCalendarCommand
|
||||||
{
|
{
|
||||||
protected static $defaultDescription = 'MSGraph: collect user metadata and create subscription on events for users, and sync the user absence-presence';
|
private static $defaultDescription = 'MSGraph: collect user metadata and create subscription on events for users, and sync the user absence-presence';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly EntityManagerInterface $em,
|
private readonly EntityManagerInterface $em,
|
||||||
@@ -43,16 +42,20 @@ final class MapAndSubscribeUserCalendarCommand extends Command
|
|||||||
private readonly UserRepositoryInterface $userRepository,
|
private readonly UserRepositoryInterface $userRepository,
|
||||||
private readonly MSUserAbsenceSync $userAbsenceSync,
|
private readonly MSUserAbsenceSync $userAbsenceSync,
|
||||||
) {
|
) {
|
||||||
parent::__construct('chill:calendar:msgraph-user-map-subscribe');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function execute(InputInterface $input, OutputInterface $output): int
|
public function __invoke(
|
||||||
|
#[\Symfony\Component\Console\Attribute\Option(name: 'renew-before-end-interval', shortcut: 'r', mode: InputOption::VALUE_OPTIONAL, description: 'delay before renewing subscription')]
|
||||||
|
string $renewBeforeEndInterval = 'P1D',
|
||||||
|
#[\Symfony\Component\Console\Attribute\Option(name: 'subscription-duration', shortcut: 's', mode: InputOption::VALUE_OPTIONAL, description: 'duration for the subscription')]
|
||||||
|
string $subscriptionDuration = 'PT4230M',
|
||||||
|
OutputInterface $output): int
|
||||||
{
|
{
|
||||||
$this->logger->info(self::class.' execute command');
|
$this->logger->info(self::class.' execute command');
|
||||||
|
|
||||||
$limit = 50;
|
$limit = 50;
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
$expiration = (new \DateTimeImmutable('now'))->add(new \DateInterval($input->getOption('subscription-duration')));
|
$expiration = (new \DateTimeImmutable('now'))->add(new \DateInterval($subscriptionDuration));
|
||||||
$users = $this->userRepository->findAllAsArray('fr');
|
$users = $this->userRepository->findAllAsArray('fr');
|
||||||
$created = 0;
|
$created = 0;
|
||||||
$renewed = 0;
|
$renewed = 0;
|
||||||
@@ -156,25 +159,4 @@ final class MapAndSubscribeUserCalendarCommand extends Command
|
|||||||
|
|
||||||
return Command::SUCCESS;
|
return Command::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure(): void
|
|
||||||
{
|
|
||||||
parent::configure();
|
|
||||||
|
|
||||||
$this
|
|
||||||
->addOption(
|
|
||||||
'renew-before-end-interval',
|
|
||||||
'r',
|
|
||||||
InputOption::VALUE_OPTIONAL,
|
|
||||||
'delay before renewing subscription',
|
|
||||||
'P1D'
|
|
||||||
)
|
|
||||||
->addOption(
|
|
||||||
'subscription-duration',
|
|
||||||
's',
|
|
||||||
InputOption::VALUE_OPTIONAL,
|
|
||||||
'duration for the subscription',
|
|
||||||
'PT4230M'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,14 +30,13 @@ use libphonenumber\PhoneNumberType;
|
|||||||
use libphonenumber\PhoneNumberUtil;
|
use libphonenumber\PhoneNumberUtil;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||||
use Symfony\Component\Console\Question\Question;
|
use Symfony\Component\Console\Question\Question;
|
||||||
use Symfony\Component\Notifier\TexterInterface;
|
use Symfony\Component\Notifier\TexterInterface;
|
||||||
|
|
||||||
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:calendar:test-send-short-message', description: 'Test sending a SMS for a dummy calendar appointment')]
|
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:calendar:test-send-short-message', description: 'Test sending a SMS for a dummy calendar appointment')]
|
||||||
class SendTestShortMessageOnCalendarCommand extends Command
|
class SendTestShortMessageOnCalendarCommand
|
||||||
{
|
{
|
||||||
protected static $defaultDescription = 'Test sending a SMS for a dummy calendar appointment';
|
protected static $defaultDescription = 'Test sending a SMS for a dummy calendar appointment';
|
||||||
|
|
||||||
@@ -48,12 +47,9 @@ class SendTestShortMessageOnCalendarCommand extends Command
|
|||||||
private readonly TexterInterface $transporter,
|
private readonly TexterInterface $transporter,
|
||||||
private readonly UserRepositoryInterface $userRepository,
|
private readonly UserRepositoryInterface $userRepository,
|
||||||
) {
|
) {
|
||||||
parent::__construct('chill:calendar:test-send-short-message');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure() {}
|
public function __invoke(OutputInterface $output): int
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
||||||
{
|
{
|
||||||
$calendar = new Calendar();
|
$calendar = new Calendar();
|
||||||
$calendar->setSendSMS(true);
|
$calendar->setSendSMS(true);
|
||||||
|
|||||||
@@ -499,15 +499,9 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
|||||||
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||||
{
|
{
|
||||||
$metadata->addPropertyConstraint('startDate', new NotBlank());
|
$metadata->addPropertyConstraint('startDate', new NotBlank());
|
||||||
$metadata->addPropertyConstraint('startDate', new Range([
|
$metadata->addPropertyConstraint('startDate', new Range(min: '2 years ago', max: '+ 2 years'));
|
||||||
'min' => '2 years ago',
|
|
||||||
'max' => '+ 2 years',
|
|
||||||
]));
|
|
||||||
$metadata->addPropertyConstraint('endDate', new NotBlank());
|
$metadata->addPropertyConstraint('endDate', new NotBlank());
|
||||||
$metadata->addPropertyConstraint('endDate', new Range([
|
$metadata->addPropertyConstraint('endDate', new Range(min: '2 years ago', max: '+ 2 years'));
|
||||||
'min' => '2 years ago',
|
|
||||||
'max' => '+ 2 years',
|
|
||||||
]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -156,10 +156,6 @@ class CalendarRangeRepository implements ObjectRepository
|
|||||||
$qb->expr()->isNull('calendar')
|
$qb->expr()->isNull('calendar')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
->setParameters([
|
->setParameters(new \Doctrine\Common\Collections\ArrayCollection([new \Doctrine\ORM\Query\Parameter('user', $user), new \Doctrine\ORM\Query\Parameter('startDate', $from), new \Doctrine\ORM\Query\Parameter('endDate', $to)]));
|
||||||
'user' => $user,
|
|
||||||
'startDate' => $from,
|
|
||||||
'endDate' => $to,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,11 +193,7 @@ class CalendarRepository implements ObjectRepository
|
|||||||
$qb->expr()->lte('c.endDate', ':endDate'),
|
$qb->expr()->lte('c.endDate', ':endDate'),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
->setParameters([
|
->setParameters(new \Doctrine\Common\Collections\ArrayCollection([new \Doctrine\ORM\Query\Parameter('user', $user), new \Doctrine\ORM\Query\Parameter('startDate', $from), new \Doctrine\ORM\Query\Parameter('endDate', $to)]));
|
||||||
'user' => $user,
|
|
||||||
'startDate' => $from,
|
|
||||||
'endDate' => $to,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function queryByNotificationAvailable(\DateTimeImmutable $startDate, \DateTimeImmutable $endDate): QueryBuilder
|
private function queryByNotificationAvailable(\DateTimeImmutable $startDate, \DateTimeImmutable $endDate): QueryBuilder
|
||||||
@@ -216,13 +212,7 @@ class CalendarRepository implements ObjectRepository
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$qb->setParameters([
|
$qb->setParameters(new \Doctrine\Common\Collections\ArrayCollection([new \Doctrine\ORM\Query\Parameter('true', true), new \Doctrine\ORM\Query\Parameter('startDate', $startDate), new \Doctrine\ORM\Query\Parameter('endDate', $endDate), new \Doctrine\ORM\Query\Parameter('pending', Calendar::SMS_PENDING), new \Doctrine\ORM\Query\Parameter('cancel_pending', Calendar::SMS_CANCEL_PENDING)]));
|
||||||
'true' => true,
|
|
||||||
'startDate' => $startDate,
|
|
||||||
'endDate' => $endDate,
|
|
||||||
'pending' => Calendar::SMS_PENDING,
|
|
||||||
'cancel_pending' => Calendar::SMS_CANCEL_PENDING,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $qb;
|
return $qb;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
|||||||
* @method CancelReason|null findOneBy(array $criteria, array $orderBy = null)
|
* @method CancelReason|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
* @method CancelReason[] findAll()
|
* @method CancelReason[] findAll()
|
||||||
* @method CancelReason[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
* @method CancelReason[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\CalendarBundle\Entity\CancelReason>
|
||||||
*/
|
*/
|
||||||
class CancelReasonRepository extends ServiceEntityRepository
|
class CancelReasonRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class CalendarDocVoter extends Voter
|
|||||||
return \in_array($attribute, self::ALL, true) && ($subject instanceof CalendarDoc || $subject instanceof Calendar);
|
return \in_array($attribute, self::ALL, true) && ($subject instanceof CalendarDoc || $subject instanceof Calendar);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
if ($subject instanceof Calendar) {
|
if ($subject instanceof Calendar) {
|
||||||
return match ($attribute) {
|
return match ($attribute) {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class InviteVoter extends Voter
|
|||||||
* @param string $attribute
|
* @param string $attribute
|
||||||
* @param Invite $subject
|
* @param Invite $subject
|
||||||
*/
|
*/
|
||||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
return $token->getUser() === $subject->getUser();
|
return $token->getUser() === $subject->getUser();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ use Chill\CustomFieldsBundle\Service\CustomFieldProvider;
|
|||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Helper\Table;
|
use Symfony\Component\Console\Helper\Table;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Console\Question\Question;
|
use Symfony\Component\Console\Question\Question;
|
||||||
@@ -30,7 +29,7 @@ use Symfony\Component\Yaml\Parser;
|
|||||||
* Create custom fields from a yml file.
|
* Create custom fields from a yml file.
|
||||||
*/
|
*/
|
||||||
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:custom_fields:populate_group')]
|
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:custom_fields:populate_group')]
|
||||||
class CreateFieldsOnGroupCommand extends Command
|
class CreateFieldsOnGroupCommand
|
||||||
{
|
{
|
||||||
protected static $defaultDescription = 'Create custom fields from a yml file';
|
protected static $defaultDescription = 'Create custom fields from a yml file';
|
||||||
final public const ARG_DELETE = 'delete';
|
final public const ARG_DELETE = 'delete';
|
||||||
@@ -47,23 +46,6 @@ class CreateFieldsOnGroupCommand extends Command
|
|||||||
private $availableLanguages,
|
private $availableLanguages,
|
||||||
private $customizablesEntities,
|
private $customizablesEntities,
|
||||||
) {
|
) {
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function configure()
|
|
||||||
{
|
|
||||||
$this
|
|
||||||
->addArgument(
|
|
||||||
self::ARG_PATH,
|
|
||||||
InputOption::VALUE_REQUIRED,
|
|
||||||
'Path to description file'
|
|
||||||
)
|
|
||||||
->addOption(
|
|
||||||
self::ARG_DELETE,
|
|
||||||
null,
|
|
||||||
InputOption::VALUE_NONE,
|
|
||||||
'If set, delete existing fields'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,7 +62,9 @@ class CreateFieldsOnGroupCommand extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: self::ARG_PATH, description: 'Path to description file')]
|
||||||
|
?string $path, #[\Symfony\Component\Console\Attribute\Option(name: self::ARG_DELETE, mode: InputOption::VALUE_NONE, description: 'If set, delete existing fields')]
|
||||||
|
bool $delete = false, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
$helper = $this->getHelperSet()->get('question');
|
$helper = $this->getHelperSet()->get('question');
|
||||||
|
|
||||||
@@ -120,12 +104,12 @@ class CreateFieldsOnGroupCommand extends Command
|
|||||||
);
|
);
|
||||||
$customFieldsGroup = $helper->ask($input, $output, $question);
|
$customFieldsGroup = $helper->ask($input, $output, $question);
|
||||||
|
|
||||||
if ($input->getOption(self::ARG_DELETE)) {
|
if ($delete) {
|
||||||
$this->deleteFieldsForCFGroup($customFieldsGroup);
|
$this->deleteFieldsForCFGroup($customFieldsGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
$fieldsInput = $this->_parse(
|
$fieldsInput = $this->_parse(
|
||||||
$input->getArgument(self::ARG_PATH),
|
$path,
|
||||||
$output
|
$output
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class CustomFieldNumber extends AbstractCustomField
|
|||||||
'scale' => 0,
|
'scale' => 0,
|
||||||
'label' => 'Precision',
|
'label' => 'Precision',
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
new GreaterThanOrEqual(['value' => 0]),
|
new GreaterThanOrEqual(value: 0),
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
->add(self::POST_TEXT, TextType::class, [
|
->add(self::POST_TEXT, TextType::class, [
|
||||||
@@ -136,11 +136,11 @@ class CustomFieldNumber extends AbstractCustomField
|
|||||||
|
|
||||||
// add constraints if required
|
// add constraints if required
|
||||||
if (null !== $options[self::MIN]) {
|
if (null !== $options[self::MIN]) {
|
||||||
$fieldOptions['constraints'][] = new GreaterThanOrEqual(['value' => $options[self::MIN]]);
|
$fieldOptions['constraints'][] = new GreaterThanOrEqual(value: $options[self::MIN]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $options[self::MAX]) {
|
if (null !== $options[self::MAX]) {
|
||||||
$fieldOptions['constraints'][] = new LessThanOrEqual(['value' => $options[self::MAX]]);
|
$fieldOptions['constraints'][] = new LessThanOrEqual(value: $options[self::MAX]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add precision to options if required
|
// add precision to options if required
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ use Chill\CustomFieldsBundle\Entity\CustomFieldsDefaultGroup;
|
|||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\CustomFieldsBundle\Entity\CustomFieldsDefaultGroup>
|
||||||
|
*/
|
||||||
class CustomFieldsDefaultGroupRepository extends ServiceEntityRepository
|
class CustomFieldsDefaultGroupRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
public function __construct(ManagerRegistry $registry)
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ class CustomFieldRenderingTwig extends AbstractExtension
|
|||||||
],
|
],
|
||||||
'needs_environment' => true,
|
'needs_environment' => true,
|
||||||
]),
|
]),
|
||||||
new TwigFunction('chill_custom_field_is_empty', $this->isEmptyValue(...)),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,6 +63,7 @@ class CustomFieldRenderingTwig extends AbstractExtension
|
|||||||
return 'chill_custom_fields_rendering';
|
return 'chill_custom_fields_rendering';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[\Twig\Attribute\AsTwigFunction('chill_custom_field_is_empty')]
|
||||||
public function isEmptyValue($fields, CustomField $customField)
|
public function isEmptyValue($fields, CustomField $customField)
|
||||||
{
|
{
|
||||||
return $this->customFieldsHelper
|
return $this->customFieldsHelper
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ class ConfigureOpenstackObjectStorageCommand extends Command
|
|||||||
$this->tempUrlKey = $config['temp_url_key'];
|
$this->tempUrlKey = $config['temp_url_key'];
|
||||||
$this->basePath = $config['temp_url_base_path'];
|
$this->basePath = $config['temp_url_base_path'];
|
||||||
|
|
||||||
parent::__construct();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure()
|
protected function configure()
|
||||||
|
|||||||
@@ -15,27 +15,19 @@ use Chill\DocStoreBundle\AsyncUpload\TempUrlGeneratorInterface;
|
|||||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
use Twig\Extension\AbstractExtension;
|
use Twig\Extension\AbstractExtension;
|
||||||
use Twig\TwigFilter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class extends the AbstractExtension class and provides Twig filter functions for generating URLs for asynchronous
|
* This class extends the AbstractExtension class and provides Twig filter functions for generating URLs for asynchronous
|
||||||
* file uploads.
|
* file uploads.
|
||||||
*/
|
*/
|
||||||
class AsyncUploadExtension extends AbstractExtension
|
class AsyncUploadExtension
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly TempUrlGeneratorInterface $tempUrlGenerator,
|
private readonly TempUrlGeneratorInterface $tempUrlGenerator,
|
||||||
private readonly UrlGeneratorInterface $routingUrlGenerator,
|
private readonly UrlGeneratorInterface $routingUrlGenerator,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function getFilters()
|
#[\Twig\Attribute\AsTwigFilter('file_url')]
|
||||||
{
|
|
||||||
return [
|
|
||||||
new TwigFilter('file_url', $this->computeSignedUrl(...)),
|
|
||||||
new TwigFilter('generate_url', $this->computeGenerateUrl(...)),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function computeSignedUrl(StoredObject|string $file, string $method = 'GET', ?int $expiresDelay = null): string
|
public function computeSignedUrl(StoredObject|string $file, string $method = 'GET', ?int $expiresDelay = null): string
|
||||||
{
|
{
|
||||||
if ($file instanceof StoredObject) {
|
if ($file instanceof StoredObject) {
|
||||||
@@ -47,6 +39,7 @@ class AsyncUploadExtension extends AbstractExtension
|
|||||||
return $this->tempUrlGenerator->generate($method, $object_name, $expiresDelay)->url;
|
return $this->tempUrlGenerator->generate($method, $object_name, $expiresDelay)->url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[\Twig\Attribute\AsTwigFilter('generate_url')]
|
||||||
public function computeGenerateUrl(StoredObject|string $file, string $method = 'GET', ?int $expiresDelay = null): string
|
public function computeGenerateUrl(StoredObject|string $file, string $method = 'GET', ?int $expiresDelay = null): string
|
||||||
{
|
{
|
||||||
if ($file instanceof StoredObject) {
|
if ($file instanceof StoredObject) {
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
|||||||
* @method AccompanyingCourseDocument|null findOneBy(array $criteria, array $orderBy = null)
|
* @method AccompanyingCourseDocument|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
* @method AccompanyingCourseDocument[] findAll()
|
* @method AccompanyingCourseDocument[] findAll()
|
||||||
* @method AccompanyingCourseDocument[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
* @method AccompanyingCourseDocument[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\DocStoreBundle\Entity\AccompanyingCourseDocument>
|
||||||
*/
|
*/
|
||||||
class AccompanyingCourseDocumentRepository extends ServiceEntityRepository
|
class AccompanyingCourseDocumentRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @template-extends ServiceEntityRepository<StoredObjectPointInTime>
|
* @template-extends ServiceEntityRepository<StoredObjectPointInTime>
|
||||||
|
*
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\DocStoreBundle\Entity\StoredObjectPointInTime>
|
||||||
*/
|
*/
|
||||||
class StoredObjectPointInTimeRepository extends ServiceEntityRepository
|
class StoredObjectPointInTimeRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ final class AsyncUploadVoter extends Voter
|
|||||||
return self::GENERATE_SIGNATURE === $attribute && $subject instanceof SignedUrl;
|
return self::GENERATE_SIGNATURE === $attribute && $subject instanceof SignedUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
/** @var SignedUrl $subject */
|
/** @var SignedUrl $subject */
|
||||||
if (!in_array($subject->method, ['POST', 'GET', 'HEAD', 'PUT'], true)) {
|
if (!in_array($subject->method, ['POST', 'GET', 'HEAD', 'PUT'], true)) {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class StoredObjectVoter extends Voter
|
|||||||
&& $subject instanceof StoredObject;
|
&& $subject instanceof StoredObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
/** @var StoredObject $subject */
|
/** @var StoredObject $subject */
|
||||||
$attributeAsEnum = StoredObjectRoleEnum::from($attribute);
|
$attributeAsEnum = StoredObjectRoleEnum::from($attribute);
|
||||||
|
|||||||
@@ -77,15 +77,13 @@ class ListEvents implements ListInterface, GroupedExportInterface
|
|||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choices' => array_combine($this->fields, $this->fields),
|
'choices' => array_combine($this->fields, $this->fields),
|
||||||
'label' => 'Fields to include in export',
|
'label' => 'Fields to include in export',
|
||||||
'constraints' => [new Callback([
|
'constraints' => [new Callback(callback: static function ($selected, ExecutionContextInterface $context) {
|
||||||
'callback' => static function ($selected, ExecutionContextInterface $context) {
|
if (0 === \count($selected)) {
|
||||||
if (0 === \count($selected)) {
|
$context->buildViolation('You must select at least one element')
|
||||||
$context->buildViolation('You must select at least one element')
|
->atPath('fields')
|
||||||
->atPath('fields')
|
->addViolation();
|
||||||
->addViolation();
|
}
|
||||||
}
|
})],
|
||||||
},
|
|
||||||
])],
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ParticipationRepository.
|
* Class ParticipationRepository.
|
||||||
|
*
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\EventBundle\Entity\Participation>
|
||||||
*/
|
*/
|
||||||
class ParticipationRepository extends ServiceEntityRepository
|
class ParticipationRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ use Chill\EventBundle\Entity\Status;
|
|||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\EventBundle\Entity\Status>
|
||||||
|
*/
|
||||||
class StatusRepository extends ServiceEntityRepository
|
class StatusRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
public function __construct(ManagerRegistry $registry)
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
|||||||
@@ -99,16 +99,14 @@ class ListCV implements ListInterface, ExportElementValidatedInterface
|
|||||||
'data' => array_combine($this->getFields(), $this->getFields()),
|
'data' => array_combine($this->getFields(), $this->getFields()),
|
||||||
'choice_attr' => [],
|
'choice_attr' => [],
|
||||||
'attr' => ['class' => ''],
|
'attr' => ['class' => ''],
|
||||||
'constraints' => [new Callback([
|
'constraints' => [new Callback(callback: function ($selected, ExecutionContextInterface $context) {
|
||||||
'callback' => function ($selected, ExecutionContextInterface $context) {
|
if (0 === count($selected)) {
|
||||||
if (0 === count($selected)) {
|
$context
|
||||||
$context
|
->buildViolation('You must select at least one element')
|
||||||
->buildViolation('You must select at least one element')
|
->atPath('fields')
|
||||||
->atPath('fields')
|
->addViolation();
|
||||||
->addViolation();
|
}
|
||||||
}
|
})],
|
||||||
},
|
|
||||||
])],
|
|
||||||
])
|
])
|
||||||
->add('reportdate_min', ChillDateType::class, [
|
->add('reportdate_min', ChillDateType::class, [
|
||||||
'label' => 'Date du rapport après le',
|
'label' => 'Date du rapport après le',
|
||||||
|
|||||||
@@ -112,16 +112,14 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface
|
|||||||
'data' => array_combine($this->getFields(), $this->getFields()),
|
'data' => array_combine($this->getFields(), $this->getFields()),
|
||||||
'choice_attr' => [],
|
'choice_attr' => [],
|
||||||
'attr' => ['class' => ''],
|
'attr' => ['class' => ''],
|
||||||
'constraints' => [new Callback([
|
'constraints' => [new Callback(callback: function ($selected, ExecutionContextInterface $context) {
|
||||||
'callback' => function ($selected, ExecutionContextInterface $context) {
|
if (0 === count($selected)) {
|
||||||
if (0 === count($selected)) {
|
$context
|
||||||
$context
|
->buildViolation('You must select at least one element')
|
||||||
->buildViolation('You must select at least one element')
|
->atPath('fields')
|
||||||
->atPath('fields')
|
->addViolation();
|
||||||
->addViolation();
|
}
|
||||||
}
|
})],
|
||||||
},
|
|
||||||
])],
|
|
||||||
])
|
])
|
||||||
->add('reportdate_min', ChillDateType::class, [
|
->add('reportdate_min', ChillDateType::class, [
|
||||||
'label' => 'Date du rapport après le',
|
'label' => 'Date du rapport après le',
|
||||||
|
|||||||
@@ -118,16 +118,14 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn
|
|||||||
'data' => array_combine($this->getFields(), $this->getFields()),
|
'data' => array_combine($this->getFields(), $this->getFields()),
|
||||||
'choice_attr' => [],
|
'choice_attr' => [],
|
||||||
'attr' => ['class' => ''],
|
'attr' => ['class' => ''],
|
||||||
'constraints' => [new Callback([
|
'constraints' => [new Callback(callback: function ($selected, ExecutionContextInterface $context) {
|
||||||
'callback' => function ($selected, ExecutionContextInterface $context) {
|
if (0 === count($selected)) {
|
||||||
if (0 === count($selected)) {
|
$context
|
||||||
$context
|
->buildViolation('You must select at least one element')
|
||||||
->buildViolation('You must select at least one element')
|
->atPath('fields')
|
||||||
->atPath('fields')
|
->addViolation();
|
||||||
->addViolation();
|
}
|
||||||
}
|
})],
|
||||||
},
|
|
||||||
])],
|
|
||||||
])
|
])
|
||||||
->add('reportdate_min', ChillDateType::class, [
|
->add('reportdate_min', ChillDateType::class, [
|
||||||
'label' => 'Date du rapport après le',
|
'label' => 'Date du rapport après le',
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ use League\Csv\Reader;
|
|||||||
use League\Csv\Writer;
|
use League\Csv\Writer;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
@@ -30,8 +29,10 @@ use Symfony\Component\Console\Question\ConfirmationQuestion;
|
|||||||
use Symfony\Component\Validator\ConstraintViolationListInterface;
|
use Symfony\Component\Validator\ConstraintViolationListInterface;
|
||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
|
|
||||||
#[\Symfony\Component\Console\Attribute\AsCommand(name:'chill:main:import-users')]
|
#[\Symfony\Component\Console\Attribute\AsCommand(name:'chill:main:import-users', help: <<<'TXT'
|
||||||
class ChillImportUsersCommand extends Command
|
Import users from a csv file. Users are added to centers contained in the file. Headers are used to detect columns. Adding to multiple centers can be done by using a `grouping centers` file, which will group multiple centers into a signle alias, used in 'centers' column.
|
||||||
|
TXT)]
|
||||||
|
class ChillImportUsersCommand
|
||||||
{
|
{
|
||||||
protected static $defaultDescription = 'Import users from csv file';
|
protected static $defaultDescription = 'Import users from csv file';
|
||||||
/**
|
/**
|
||||||
@@ -60,7 +61,6 @@ class ChillImportUsersCommand extends Command
|
|||||||
protected ValidatorInterface $validator,
|
protected ValidatorInterface $validator,
|
||||||
protected UserRepository $userRepository,
|
protected UserRepository $userRepository,
|
||||||
) {
|
) {
|
||||||
parent::__construct('chill:main:import-users');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function appendUserToFile(User $user)
|
protected function appendUserToFile(User $user)
|
||||||
@@ -84,16 +84,6 @@ class ChillImportUsersCommand extends Command
|
|||||||
return \implode(';', $str);
|
return \implode(';', $str);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure()
|
|
||||||
{
|
|
||||||
$this
|
|
||||||
->setHelp("Import users from a csv file. Users are added to centers contained in the file. Headers are used to detect columns. Adding to multiple centers can be done by using a `grouping centers` file, which will group multiple centers into a signle alias, used in 'centers' column.")
|
|
||||||
->addArgument('csvfile', InputArgument::REQUIRED, 'Path to the csv file. Columns are: `username`, `email`, `center` (can contain alias), `permission group`')
|
|
||||||
->addOption('grouping-centers', null, InputOption::VALUE_OPTIONAL, 'Path to a csv file to aggregate multiple centers into a single alias')
|
|
||||||
->addOption('dry-run', null, InputOption::VALUE_NONE, 'Do not commit the changes')
|
|
||||||
->addOption('csv-dump', null, InputOption::VALUE_REQUIRED, 'A path to dump a summary of the created file');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function createOrGetGroupCenter(Center $center, PermissionsGroup $pg): GroupCenter
|
protected function createOrGetGroupCenter(Center $center, PermissionsGroup $pg): GroupCenter
|
||||||
{
|
{
|
||||||
if (\array_key_exists($center->getId(), $this->groupCenters)) {
|
if (\array_key_exists($center->getId(), $this->groupCenters)) {
|
||||||
@@ -186,12 +176,16 @@ class ChillImportUsersCommand extends Command
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'csvfile', description: 'Path to the csv file. Columns are: `username`, `email`, `center` (can contain alias), `permission group`')]
|
||||||
|
string $csvfile, #[\Symfony\Component\Console\Attribute\Option(name: 'grouping-centers', mode: InputOption::VALUE_OPTIONAL, description: 'Path to a csv file to aggregate multiple centers into a single alias')]
|
||||||
|
$groupingCenters, #[\Symfony\Component\Console\Attribute\Option(name: 'dry-run', mode: InputOption::VALUE_NONE, description: 'Do not commit the changes')]
|
||||||
|
bool $dryRun = false, #[\Symfony\Component\Console\Attribute\Option(name: 'csv-dump', mode: InputOption::VALUE_REQUIRED, description: 'A path to dump a summary of the created file')]
|
||||||
|
$csvDump, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
$this->tempOutput = $output;
|
$this->tempOutput = $output;
|
||||||
$this->tempInput = $input;
|
$this->tempInput = $input;
|
||||||
|
|
||||||
if ($input->getOption('dry-run')) {
|
if ($dry_run) {
|
||||||
$this->doChanges = false;
|
$this->doChanges = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
use League\Csv\Reader;
|
use League\Csv\Reader;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
@@ -28,7 +27,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|||||||
* Class ChillUserSendRenewPasswordCodeCommand.
|
* Class ChillUserSendRenewPasswordCodeCommand.
|
||||||
*/
|
*/
|
||||||
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:user:send-password-recover-code')]
|
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:user:send-password-recover-code')]
|
||||||
class ChillUserSendRenewPasswordCodeCommand extends Command
|
class ChillUserSendRenewPasswordCodeCommand
|
||||||
{
|
{
|
||||||
protected static $defaultDescription = 'Send a message with code to recover password';
|
protected static $defaultDescription = 'Send a message with code to recover password';
|
||||||
/**
|
/**
|
||||||
@@ -77,19 +76,13 @@ class ChillUserSendRenewPasswordCodeCommand extends Command
|
|||||||
$this->recoverPasswordHelper = $recoverPasswordHelper;
|
$this->recoverPasswordHelper = $recoverPasswordHelper;
|
||||||
$this->eventDispatcher = $eventDispatcher;
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
|
|
||||||
parent::__construct();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure()
|
public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'csvfile', description: 'CSV file with the list of users')]
|
||||||
{
|
string $csvfile, #[\Symfony\Component\Console\Attribute\Option(name: 'template', mode: InputOption::VALUE_REQUIRED, description: 'Template for email')]
|
||||||
$this
|
$template, #[\Symfony\Component\Console\Attribute\Option(name: 'expiration', mode: InputOption::VALUE_REQUIRED, description: 'Expiration of the link, as an unix timestamp')]
|
||||||
->addArgument('csvfile', InputArgument::REQUIRED, 'CSV file with the list of users')
|
$expiration, #[\Symfony\Component\Console\Attribute\Option(name: 'subject', mode: InputOption::VALUE_REQUIRED, description: 'Subject of the email')]
|
||||||
->addOption('template', null, InputOption::VALUE_REQUIRED, 'Template for email')
|
string $subject = 'Recover your password', OutputInterface $output): int
|
||||||
->addOption('expiration', null, InputOption::VALUE_REQUIRED, 'Expiration of the link, as an unix timestamp')
|
|
||||||
->addOption('subject', null, InputOption::VALUE_REQUIRED, 'Subject of the email', 'Recover your password');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
||||||
{
|
{
|
||||||
$this->input = $input;
|
$this->input = $input;
|
||||||
$this->output = $output;
|
$this->output = $output;
|
||||||
|
|||||||
@@ -14,18 +14,16 @@ namespace Chill\MainBundle\Command;
|
|||||||
use Chill\MainBundle\Security\RoleDumper;
|
use Chill\MainBundle\Security\RoleDumper;
|
||||||
use Symfony\Component\Console\Attribute\AsCommand;
|
use Symfony\Component\Console\Attribute\AsCommand;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
#[AsCommand(name: 'chill:main:dump-list-permissions', description: 'Print a markdown reference of permissions (roles) grouped by title with dependencies).')]
|
#[AsCommand(name: 'chill:main:dump-list-permissions', description: 'Print a markdown reference of permissions (roles) grouped by title with dependencies).')]
|
||||||
final class DumpListPermissionsCommand extends Command
|
final class DumpListPermissionsCommand
|
||||||
{
|
{
|
||||||
public function __construct(private readonly RoleDumper $roleDumper)
|
public function __construct(private readonly RoleDumper $roleDumper)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
public function __invoke(OutputInterface $output): int
|
||||||
{
|
{
|
||||||
$markdown = $this->roleDumper->dumpAsMarkdown();
|
$markdown = $this->roleDumper->dumpAsMarkdown();
|
||||||
$output->writeln($markdown);
|
$output->writeln($markdown);
|
||||||
|
|||||||
@@ -14,37 +14,37 @@ namespace Chill\MainBundle\Command;
|
|||||||
use Chill\MainBundle\Cron\CronManagerInterface;
|
use Chill\MainBundle\Cron\CronManagerInterface;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
|
||||||
|
|
||||||
#[\Symfony\Component\Console\Attribute\AsCommand(name:'chill:cron-job:execute')]
|
#[\Symfony\Component\Console\Attribute\AsCommand(name:'chill:cron-job:execute', help: <<<'TXT'
|
||||||
class ExecuteCronJobCommand extends Command
|
If no job is specified, the next available cronjob will be executed by system.
|
||||||
|
This command should be execute every 15 minutes (more or less)
|
||||||
|
TXT)]
|
||||||
|
class ExecuteCronJobCommand
|
||||||
{
|
{
|
||||||
protected static $defaultDescription = 'Execute the cronjob(s) given as argument, or one cronjob scheduled by system.';
|
protected static $defaultDescription = 'Execute the cronjob(s) given as argument, or one cronjob scheduled by system.';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly CronManagerInterface $cronManager,
|
private readonly CronManagerInterface $cronManager,
|
||||||
) {
|
) {
|
||||||
parent::__construct('chill:cron-job:execute');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setHelp("If no job is specified, the next available cronjob will be executed by system.\nThis command should be execute every 15 minutes (more or less)")
|
|
||||||
->addArgument('job', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'one or more job to force execute (by default, all jobs are executed)', [])
|
->addArgument('job', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'one or more job to force execute (by default, all jobs are executed)', [])
|
||||||
->addUsage('');
|
->addUsage('');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
public function __invoke(
|
||||||
{
|
#[\Symfony\Component\Console\Attribute\Argument(name: 'job', description: 'one or more job to force execute (by default, all jobs are executed)')]
|
||||||
if ([] === $input->getArgument('job')) {
|
array $job = [],
|
||||||
|
): int {
|
||||||
|
if ([] === $job) {
|
||||||
$this->cronManager->run();
|
$this->cronManager->run();
|
||||||
|
|
||||||
return Command::SUCCESS;
|
return Command::SUCCESS;
|
||||||
}
|
}
|
||||||
|
foreach ($job as $jobName) {
|
||||||
foreach ($input->getArgument('job') as $jobName) {
|
|
||||||
$this->cronManager->run($jobName);
|
$this->cronManager->run($jobName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,13 +14,10 @@ namespace Chill\MainBundle\Command;
|
|||||||
use Chill\MainBundle\Service\Import\AddressReferenceBEFromBestAddress;
|
use Chill\MainBundle\Service\Import\AddressReferenceBEFromBestAddress;
|
||||||
use Chill\MainBundle\Service\Import\PostalCodeBEFromBestAddress;
|
use Chill\MainBundle\Service\Import\PostalCodeBEFromBestAddress;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
|
||||||
|
|
||||||
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:address-ref-from-best-addresses')]
|
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:address-ref-from-best-addresses')]
|
||||||
class LoadAddressesBEFromBestAddressCommand extends Command
|
class LoadAddressesBEFromBestAddressCommand
|
||||||
{
|
{
|
||||||
protected static $defaultDescription = 'Import BE addresses from BeST Address (see https://osoc19.github.io/best/)';
|
protected static $defaultDescription = 'Import BE addresses from BeST Address (see https://osoc19.github.io/best/)';
|
||||||
|
|
||||||
@@ -28,25 +25,21 @@ class LoadAddressesBEFromBestAddressCommand extends Command
|
|||||||
private readonly AddressReferenceBEFromBestAddress $addressImporter,
|
private readonly AddressReferenceBEFromBestAddress $addressImporter,
|
||||||
private readonly PostalCodeBEFromBestAddress $postalCodeBEFromBestAddressImporter,
|
private readonly PostalCodeBEFromBestAddress $postalCodeBEFromBestAddressImporter,
|
||||||
) {
|
) {
|
||||||
parent::__construct();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure()
|
public function __invoke(
|
||||||
{
|
#[\Symfony\Component\Console\Attribute\Argument(name: 'lang', description: "Language code, for example 'fr'")]
|
||||||
$this
|
string $lang,
|
||||||
->addArgument('lang', InputArgument::REQUIRED, "Language code, for example 'fr'")
|
#[\Symfony\Component\Console\Attribute\Argument(name: 'list', description: "The list to add, for example 'full', or 'extract' (dev) or '1xxx' (brussel CP)")]
|
||||||
->addArgument('list', InputArgument::IS_ARRAY, "The list to add, for example 'full', or 'extract' (dev) or '1xxx' (brussel CP)")
|
array $list,
|
||||||
->addOption('send-report-email', 's', InputOption::VALUE_REQUIRED, 'Email address where a list of unimported addresses can be send');
|
#[\Symfony\Component\Console\Attribute\Option(name: 'send-report-email', shortcut: 's', mode: InputOption::VALUE_REQUIRED, description: 'Email address where a list of unimported addresses can be send')]
|
||||||
}
|
$sendReportEmail,
|
||||||
|
): int {
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
||||||
{
|
|
||||||
$this->postalCodeBEFromBestAddressImporter->import();
|
$this->postalCodeBEFromBestAddressImporter->import();
|
||||||
|
|
||||||
$this->addressImporter->import(
|
$this->addressImporter->import(
|
||||||
$input->getArgument('lang'),
|
$lang,
|
||||||
$input->getArgument('list'),
|
$list,
|
||||||
$input->hasOption('send-report-email') ? $input->getOption('send-report-email') : null
|
$input->hasOption('send-report-email') ? $send_report_email : null
|
||||||
);
|
);
|
||||||
|
|
||||||
return Command::SUCCESS;
|
return Command::SUCCESS;
|
||||||
|
|||||||
@@ -13,35 +13,27 @@ namespace Chill\MainBundle\Command;
|
|||||||
|
|
||||||
use Chill\MainBundle\Service\Import\AddressReferenceFromBAN;
|
use Chill\MainBundle\Service\Import\AddressReferenceFromBAN;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:address-ref-from-ban')]
|
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:address-ref-from-ban')]
|
||||||
class LoadAddressesFRFromBANCommand extends Command
|
class LoadAddressesFRFromBANCommand
|
||||||
{
|
{
|
||||||
protected static $defaultDescription = 'Import FR addresses from BAN (see https://adresses.data.gouv.fr';
|
protected static $defaultDescription = 'Import FR addresses from BAN (see https://adresses.data.gouv.fr';
|
||||||
|
|
||||||
public function __construct(private readonly AddressReferenceFromBAN $addressReferenceFromBAN)
|
public function __construct(private readonly AddressReferenceFromBAN $addressReferenceFromBAN)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure()
|
public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'departementNo', description: 'a list of departement numbers')]
|
||||||
{
|
array $departementno, #[\Symfony\Component\Console\Attribute\Option(name: 'send-report-email', shortcut: 's', mode: InputOption::VALUE_REQUIRED, description: 'Email address where a list of unimported addresses can be send')]
|
||||||
$this
|
$sendReportEmail, OutputInterface $output): int
|
||||||
->addArgument('departementNo', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'a list of departement numbers')
|
|
||||||
->addOption('send-report-email', 's', InputOption::VALUE_REQUIRED, 'Email address where a list of unimported addresses can be send');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
||||||
{
|
{
|
||||||
dump(__METHOD__);
|
dump(__METHOD__);
|
||||||
foreach ($input->getArgument('departementNo') as $departementNo) {
|
foreach ($departementNo as $departementNo) {
|
||||||
$output->writeln('Import addresses for '.$departementNo);
|
$output->writeln('Import addresses for '.$departementNo);
|
||||||
|
|
||||||
$this->addressReferenceFromBAN->import($departementNo, $input->hasOption('send-report-email') ? $input->getOption('send-report-email') : null);
|
$this->addressReferenceFromBAN->import($departementNo, $input->hasOption('send-report-email') ? $send_report_email : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Command::SUCCESS;
|
return Command::SUCCESS;
|
||||||
|
|||||||
@@ -13,34 +13,26 @@ namespace Chill\MainBundle\Command;
|
|||||||
|
|
||||||
use Chill\MainBundle\Service\Import\AddressReferenceFromBano;
|
use Chill\MainBundle\Service\Import\AddressReferenceFromBano;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:address-ref-from-bano')]
|
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:address-ref-from-bano')]
|
||||||
class LoadAddressesFRFromBANOCommand extends Command
|
class LoadAddressesFRFromBANOCommand
|
||||||
{
|
{
|
||||||
protected static $defaultDescription = 'Import FR addresses from bano (see https://bano.openstreetmap.fr';
|
protected static $defaultDescription = 'Import FR addresses from bano (see https://bano.openstreetmap.fr';
|
||||||
|
|
||||||
public function __construct(private readonly AddressReferenceFromBano $addressReferenceFromBano)
|
public function __construct(private readonly AddressReferenceFromBano $addressReferenceFromBano)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure()
|
public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'departementNo', description: 'a list of departement numbers')]
|
||||||
|
array $departementno, #[\Symfony\Component\Console\Attribute\Option(name: 'send-report-email', shortcut: 's', mode: InputOption::VALUE_REQUIRED, description: 'Email address where a list of unimported addresses can be send')]
|
||||||
|
$sendReportEmail, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
$this
|
foreach ($departementNo as $departementNo) {
|
||||||
->addArgument('departementNo', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'a list of departement numbers')
|
|
||||||
->addOption('send-report-email', 's', InputOption::VALUE_REQUIRED, 'Email address where a list of unimported addresses can be send');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
||||||
{
|
|
||||||
foreach ($input->getArgument('departementNo') as $departementNo) {
|
|
||||||
$output->writeln('Import addresses for '.$departementNo);
|
$output->writeln('Import addresses for '.$departementNo);
|
||||||
|
|
||||||
$this->addressReferenceFromBano->import($departementNo, $input->hasOption('send-report-email') ? $input->getOption('send-report-email') : null);
|
$this->addressReferenceFromBano->import($departementNo, $input->hasOption('send-report-email') ? $send_report_email : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Command::SUCCESS;
|
return Command::SUCCESS;
|
||||||
|
|||||||
@@ -13,31 +13,24 @@ namespace Chill\MainBundle\Command;
|
|||||||
|
|
||||||
use Chill\MainBundle\Service\Import\AddressReferenceLU;
|
use Chill\MainBundle\Service\Import\AddressReferenceLU;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
|
||||||
|
|
||||||
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:address-ref-lux')]
|
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:address-ref-lux')]
|
||||||
class LoadAddressesLUFromBDAddressCommand extends Command
|
class LoadAddressesLUFromBDAddressCommand
|
||||||
{
|
{
|
||||||
protected static $defaultDescription = 'Import LUX addresses from BD addresses (see https://data.public.lu/fr/datasets/adresses-georeferencees-bd-adresses/)';
|
protected static $defaultDescription = 'Import LUX addresses from BD addresses (see https://data.public.lu/fr/datasets/adresses-georeferencees-bd-adresses/)';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly AddressReferenceLU $addressImporter,
|
private readonly AddressReferenceLU $addressImporter,
|
||||||
) {
|
) {
|
||||||
parent::__construct();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure()
|
public function __invoke(
|
||||||
{
|
#[\Symfony\Component\Console\Attribute\Option(name: 'send-report-email', shortcut: 's', mode: InputOption::VALUE_REQUIRED, description: 'Email address where a list of unimported addresses can be send')]
|
||||||
$this
|
$sendReportEmail,
|
||||||
->addOption('send-report-email', 's', InputOption::VALUE_REQUIRED, 'Email address where a list of unimported addresses can be send');
|
): int {
|
||||||
}
|
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
||||||
{
|
|
||||||
$this->addressImporter->import(
|
$this->addressImporter->import(
|
||||||
$input->hasOption('send-report-email') ? $input->getOption('send-report-email') : null,
|
$input->hasOption('send-report-email') ? $send_report_email : null,
|
||||||
);
|
);
|
||||||
|
|
||||||
return Command::SUCCESS;
|
return Command::SUCCESS;
|
||||||
|
|||||||
@@ -14,9 +14,7 @@ namespace Chill\MainBundle\Command;
|
|||||||
use Chill\MainBundle\Entity\Language;
|
use Chill\MainBundle\Entity\Language;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
use Symfony\Component\Intl\Languages;
|
use Symfony\Component\Intl\Languages;
|
||||||
|
|
||||||
@@ -24,7 +22,7 @@ use Symfony\Component\Intl\Languages;
|
|||||||
* Load or update the languages entities command
|
* Load or update the languages entities command
|
||||||
*/
|
*/
|
||||||
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:languages:populate')]
|
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:languages:populate')]
|
||||||
class LoadAndUpdateLanguagesCommand extends Command
|
class LoadAndUpdateLanguagesCommand
|
||||||
{
|
{
|
||||||
final public const INCLUDE_ANCIENT = 'include_ancient';
|
final public const INCLUDE_ANCIENT = 'include_ancient';
|
||||||
|
|
||||||
@@ -43,31 +41,6 @@ class LoadAndUpdateLanguagesCommand extends Command
|
|||||||
*/
|
*/
|
||||||
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly ParameterBagInterface $parameterBag)
|
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly ParameterBagInterface $parameterBag)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* (non-PHPdoc).
|
|
||||||
*
|
|
||||||
* @see \Symfony\Component\Console\Command\Command::configure()
|
|
||||||
*/
|
|
||||||
protected function configure()
|
|
||||||
{
|
|
||||||
$this
|
|
||||||
->addOption(
|
|
||||||
self::INCLUDE_REGIONAL_VERSION,
|
|
||||||
null,
|
|
||||||
InputOption::VALUE_NONE,
|
|
||||||
'Include the regional languages. The regional languages are languages with code containing _ excepted '
|
|
||||||
.implode(',', $this->regionalVersionToInclude).'.'
|
|
||||||
)
|
|
||||||
->addOption(
|
|
||||||
self::INCLUDE_ANCIENT,
|
|
||||||
null,
|
|
||||||
InputOption::VALUE_NONE,
|
|
||||||
'Include the ancient languages that are languages with code '
|
|
||||||
.implode(', ', $this->ancientToExclude).'.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,7 +48,11 @@ class LoadAndUpdateLanguagesCommand extends Command
|
|||||||
*
|
*
|
||||||
* @see \Symfony\Component\Console\Command\Command::execute()
|
* @see \Symfony\Component\Console\Command\Command::execute()
|
||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
public function __invoke(
|
||||||
|
#[\Symfony\Component\Console\Attribute\Option(name: self::INCLUDE_REGIONAL_VERSION, mode: InputOption::VALUE_NONE, description: 'Include the regional languages. The regional languages are languages with code containing')]
|
||||||
|
bool $includeRegional = false,
|
||||||
|
#[\Symfony\Component\Console\Attribute\Option(name: self::INCLUDE_ANCIENT, mode: InputOption::VALUE_NONE, description: 'Include the ancient languages that are languages with code ')]
|
||||||
|
bool $includeAncient = false): int
|
||||||
{
|
{
|
||||||
$em = $this->entityManager;
|
$em = $this->entityManager;
|
||||||
$chillAvailableLanguages = $this->parameterBag->get('chill_main.available_languages');
|
$chillAvailableLanguages = $this->parameterBag->get('chill_main.available_languages');
|
||||||
@@ -88,11 +65,11 @@ class LoadAndUpdateLanguagesCommand extends Command
|
|||||||
foreach (Languages::getNames() as $code => $lang) {
|
foreach (Languages::getNames() as $code => $lang) {
|
||||||
$excludeCode = (
|
$excludeCode = (
|
||||||
(
|
(
|
||||||
null === $input->getOption(self::INCLUDE_REGIONAL_VERSION)
|
null === $include_regional
|
||||||
&& strpos($code, '_')
|
&& strpos($code, '_')
|
||||||
&& !\in_array($code, $this->regionalVersionToInclude, true)
|
&& !\in_array($code, $this->regionalVersionToInclude, true)
|
||||||
) || (
|
) || (
|
||||||
null === $input->getOption(self::INCLUDE_ANCIENT)
|
null === $include_ancient
|
||||||
&& \in_array($code, $this->ancientToExclude, true)
|
&& \in_array($code, $this->ancientToExclude, true)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -14,19 +14,16 @@ namespace Chill\MainBundle\Command;
|
|||||||
use Chill\MainBundle\Entity\Country;
|
use Chill\MainBundle\Entity\Country;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
|
||||||
use Symfony\Component\Intl\Countries;
|
use Symfony\Component\Intl\Countries;
|
||||||
|
|
||||||
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:countries:populate')]
|
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:countries:populate')]
|
||||||
class LoadCountriesCommand extends Command
|
class LoadCountriesCommand
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* LoadCountriesCommand constructor.
|
* LoadCountriesCommand constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct(private readonly EntityManager $entityManager, private $availableLanguages)
|
public function __construct(private readonly EntityManager $entityManager, private $availableLanguages)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function prepareCountryList($languages)
|
public static function prepareCountryList($languages)
|
||||||
@@ -49,23 +46,15 @@ class LoadCountriesCommand extends Command
|
|||||||
return $countryEntities;
|
return $countryEntities;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* (non-PHPdoc).
|
|
||||||
*
|
|
||||||
* @see \Symfony\Component\Console\Command\Command::configure()
|
|
||||||
*/
|
|
||||||
protected function configure() {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (non-PHPdoc).
|
* (non-PHPdoc).
|
||||||
*
|
*
|
||||||
* @see \Symfony\Component\Console\Command\Command::execute()
|
* @see \Symfony\Component\Console\Command\Command::execute()
|
||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
public function __invoke(): int
|
||||||
{
|
{
|
||||||
$countries = static::prepareCountryList($this->availableLanguages);
|
$countries = static::prepareCountryList($this->availableLanguages);
|
||||||
$em = $this->entityManager;
|
$em = $this->entityManager;
|
||||||
|
|
||||||
foreach ($countries as $country) {
|
foreach ($countries as $country) {
|
||||||
$countryStored = $em->getRepository(Country::class)
|
$countryStored = $em->getRepository(Country::class)
|
||||||
->findOneBy(['countryCode' => $country->getCountryCode()]);
|
->findOneBy(['countryCode' => $country->getCountryCode()]);
|
||||||
@@ -76,7 +65,6 @@ class LoadCountriesCommand extends Command
|
|||||||
$countryStored->setName($country->getName());
|
$countryStored->setName($country->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
return Command::SUCCESS;
|
return Command::SUCCESS;
|
||||||
|
|||||||
@@ -13,22 +13,17 @@ namespace Chill\MainBundle\Command;
|
|||||||
|
|
||||||
use Chill\MainBundle\Service\Import\PostalCodeFRFromOpenData;
|
use Chill\MainBundle\Service\Import\PostalCodeFRFromOpenData;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
|
||||||
|
|
||||||
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:postal-code:load:FR')]
|
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:postal-code:load:FR')]
|
||||||
class LoadPostalCodeFR extends Command
|
class LoadPostalCodeFR
|
||||||
{
|
{
|
||||||
protected static $defaultDescription = 'Load France\'s postal code from online open data';
|
protected static $defaultDescription = 'Load France\'s postal code from online open data';
|
||||||
|
|
||||||
public function __construct(private readonly PostalCodeFRFromOpenData $loader)
|
public function __construct(private readonly PostalCodeFRFromOpenData $loader)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configure(): void {}
|
public function __invoke(): int
|
||||||
|
|
||||||
public function execute(InputInterface $input, OutputInterface $output): int
|
|
||||||
{
|
{
|
||||||
$this->loader->import();
|
$this->loader->import();
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ use Chill\MainBundle\Entity\Country;
|
|||||||
use Chill\MainBundle\Entity\PostalCode;
|
use Chill\MainBundle\Entity\PostalCode;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
@@ -24,58 +23,26 @@ use Symfony\Component\Filesystem\Filesystem;
|
|||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
|
|
||||||
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:postal-code:populate')]
|
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:postal-code:populate')]
|
||||||
class LoadPostalCodesCommand extends Command
|
class LoadPostalCodesCommand
|
||||||
{
|
{
|
||||||
protected static $defaultDescription = 'Add the postal code from a csv file.';
|
protected static $defaultDescription = 'Add the postal code from a csv file.';
|
||||||
|
|
||||||
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly ValidatorInterface $validator)
|
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly ValidatorInterface $validator)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure()
|
public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'csv_file', description: 'the path to '
|
||||||
{
|
.'the csv file. See the help for specifications.')]
|
||||||
$this
|
string $csvFile, #[\Symfony\Component\Console\Attribute\Option(name: 'delimiter', shortcut: 'd', mode: InputOption::VALUE_OPTIONAL, description: 'The delimiter character of the csv file')]
|
||||||
->setHelp('This script will try to avoid existing postal code '
|
string $delimiter = ',', #[\Symfony\Component\Console\Attribute\Option(name: 'enclosure', mode: InputOption::VALUE_OPTIONAL, description: 'The enclosure character of the csv file')]
|
||||||
."using the postal code and name. \n"
|
string $enclosure = '"', #[\Symfony\Component\Console\Attribute\Option(name: 'escape', mode: InputOption::VALUE_OPTIONAL, description: 'The escape character of the csv file')]
|
||||||
.'The CSV file must have the following columns: '
|
string $escape = '\\', OutputInterface $output): int
|
||||||
.'postal code, label, country code.'
|
|
||||||
.'Optionally, the csv file can have the following '
|
|
||||||
.'columns after the country code: reference code, latitude, longitude, source. '
|
|
||||||
.'The latitude and longitude columns are supposed to be in WGS84 and expressed in decimal degrees. '
|
|
||||||
.'The CSV file should not have any header row.')
|
|
||||||
->addArgument('csv_file', InputArgument::REQUIRED, 'the path to '
|
|
||||||
.'the csv file. See the help for specifications.')
|
|
||||||
->addOption(
|
|
||||||
'delimiter',
|
|
||||||
'd',
|
|
||||||
InputOption::VALUE_OPTIONAL,
|
|
||||||
'The delimiter character of the csv file',
|
|
||||||
','
|
|
||||||
)
|
|
||||||
->addOption(
|
|
||||||
'enclosure',
|
|
||||||
null,
|
|
||||||
InputOption::VALUE_OPTIONAL,
|
|
||||||
'The enclosure character of the csv file',
|
|
||||||
'"'
|
|
||||||
)
|
|
||||||
->addOption(
|
|
||||||
'escape',
|
|
||||||
null,
|
|
||||||
InputOption::VALUE_OPTIONAL,
|
|
||||||
'The escape character of the csv file',
|
|
||||||
'\\'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
||||||
{
|
{
|
||||||
$csv = $this->getCSVResource($input);
|
$csv = $this->getCSVResource($input);
|
||||||
|
|
||||||
if (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
|
if (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
|
||||||
$output->writeln('The content of the file is ...');
|
$output->writeln('The content of the file is ...');
|
||||||
$output->write(file_get_contents($input->getArgument('csv_file')));
|
$output->write(file_get_contents($csv_file));
|
||||||
}
|
}
|
||||||
|
|
||||||
$num = 0;
|
$num = 0;
|
||||||
@@ -85,9 +52,9 @@ class LoadPostalCodesCommand extends Command
|
|||||||
false !== ($row = fgetcsv(
|
false !== ($row = fgetcsv(
|
||||||
$csv,
|
$csv,
|
||||||
0,
|
0,
|
||||||
$input->getOption('delimiter'),
|
$delimiter,
|
||||||
$input->getOption('enclosure'),
|
$enclosure,
|
||||||
(string) $input->getOption('escape')
|
(string) $escape
|
||||||
))
|
))
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ namespace Chill\MainBundle\Command;
|
|||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Security\Core\Encoder\EncoderFactory;
|
use Symfony\Component\Security\Core\Encoder\EncoderFactory;
|
||||||
|
|
||||||
@@ -23,7 +21,7 @@ use Symfony\Component\Security\Core\Encoder\EncoderFactory;
|
|||||||
* Class SetPasswordCommand.
|
* Class SetPasswordCommand.
|
||||||
*/
|
*/
|
||||||
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:user:set_password')]
|
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:user:set_password')]
|
||||||
class SetPasswordCommand extends Command
|
class SetPasswordCommand
|
||||||
{
|
{
|
||||||
protected static $defaultDescription = 'set a password to user';
|
protected static $defaultDescription = 'set a password to user';
|
||||||
|
|
||||||
@@ -32,7 +30,6 @@ class SetPasswordCommand extends Command
|
|||||||
*/
|
*/
|
||||||
public function __construct(private readonly EntityManager $entityManager)
|
public function __construct(private readonly EntityManager $entityManager)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function _getUser($username): ?object
|
public function _getUser($username): ?object
|
||||||
@@ -55,23 +52,18 @@ class SetPasswordCommand extends Command
|
|||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configure(): void
|
public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'username', description: 'the user\'s '
|
||||||
|
.'username you want to change password')]
|
||||||
|
string $username, #[\Symfony\Component\Console\Attribute\Argument(name: 'password', description: 'the new password')]
|
||||||
|
?string $password, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
$this
|
$user = $this->_getUser($username);
|
||||||
->addArgument('username', InputArgument::REQUIRED, 'the user\'s '
|
|
||||||
.'username you want to change password')
|
|
||||||
->addArgument('password', InputArgument::OPTIONAL, 'the new password');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function execute(InputInterface $input, OutputInterface $output): int
|
|
||||||
{
|
|
||||||
$user = $this->_getUser($input->getArgument('username'));
|
|
||||||
|
|
||||||
if (null === $user) {
|
if (null === $user) {
|
||||||
throw new \LogicException("The user with username '".$input->getArgument('username')."' is not found");
|
throw new \LogicException("The user with username '".$username."' is not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
$password = $input->getArgument('password');
|
$password = $password;
|
||||||
|
|
||||||
if (null === $password) {
|
if (null === $password) {
|
||||||
$dialog = $this->getHelperSet()->get('dialog');
|
$dialog = $this->getHelperSet()->get('dialog');
|
||||||
|
|||||||
@@ -13,23 +13,18 @@ namespace Chill\MainBundle\Command;
|
|||||||
|
|
||||||
use Chill\MainBundle\Service\EntityInfo\ViewEntityInfoManager;
|
use Chill\MainBundle\Service\EntityInfo\ViewEntityInfoManager;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
|
||||||
|
|
||||||
#[\Symfony\Component\Console\Attribute\AsCommand(name:'chill:db:sync-views')]
|
#[\Symfony\Component\Console\Attribute\AsCommand(name:'chill:db:sync-views')]
|
||||||
class SynchronizeEntityInfoViewsCommand extends Command
|
class SynchronizeEntityInfoViewsCommand
|
||||||
{
|
{
|
||||||
protected static $defaultDescription = 'Update or create sql views which provide info for various entities';
|
protected static $defaultDescription = 'Update or create sql views which provide info for various entities';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly ViewEntityInfoManager $viewEntityInfoManager,
|
private readonly ViewEntityInfoManager $viewEntityInfoManager,
|
||||||
) {
|
) {
|
||||||
parent::__construct('chill:db:sync-views');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure(): void {}
|
public function __invoke(): int
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
||||||
{
|
{
|
||||||
$this->viewEntityInfoManager->synchronizeOnDB();
|
$this->viewEntityInfoManager->synchronizeOnDB();
|
||||||
|
|
||||||
|
|||||||
@@ -243,21 +243,19 @@ final class PasswordController extends AbstractController
|
|||||||
->add('username_or_email', TextType::class, [
|
->add('username_or_email', TextType::class, [
|
||||||
'label' => 'Username or email',
|
'label' => 'Username or email',
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
new Callback([
|
new Callback(callback: function ($pattern, ExecutionContextInterface $context, $payload) {
|
||||||
'callback' => function ($pattern, ExecutionContextInterface $context, $payload) {
|
$qb = $this->managerRegistry->getManager()
|
||||||
$qb = $this->managerRegistry->getManager()
|
->createQueryBuilder();
|
||||||
->createQueryBuilder();
|
$qb->select('COUNT(u)')
|
||||||
$qb->select('COUNT(u)')
|
->from(User::class, 'u')
|
||||||
->from(User::class, 'u')
|
->where($qb->expr()->eq('u.usernameCanonical', 'UNACCENT(LOWER(:pattern))'))
|
||||||
->where($qb->expr()->eq('u.usernameCanonical', 'UNACCENT(LOWER(:pattern))'))
|
->orWhere($qb->expr()->eq('u.emailCanonical', 'UNACCENT(LOWER(:pattern))'))
|
||||||
->orWhere($qb->expr()->eq('u.emailCanonical', 'UNACCENT(LOWER(:pattern))'))
|
->setParameter('pattern', $pattern);
|
||||||
->setParameter('pattern', $pattern);
|
|
||||||
|
|
||||||
if (1 !== (int) $qb->getQuery()->getSingleScalarResult()) {
|
if (1 !== (int) $qb->getQuery()->getSingleScalarResult()) {
|
||||||
$context->addViolation('This username or email does not exists');
|
$context->addViolation('This username or email does not exists');
|
||||||
}
|
}
|
||||||
},
|
}),
|
||||||
]),
|
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
->add('submit', SubmitType::class, [
|
->add('submit', SubmitType::class, [
|
||||||
|
|||||||
@@ -14,24 +14,17 @@ namespace Chill\MainBundle\Doctrine\Event;
|
|||||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Doctrine\Common\EventSubscriber;
|
|
||||||
use Doctrine\ORM\Event\PrePersistEventArgs;
|
use Doctrine\ORM\Event\PrePersistEventArgs;
|
||||||
use Doctrine\ORM\Event\PreUpdateEventArgs;
|
use Doctrine\ORM\Event\PreUpdateEventArgs;
|
||||||
use Doctrine\ORM\Events;
|
use Doctrine\ORM\Events;
|
||||||
use Symfony\Bundle\SecurityBundle\Security;
|
use Symfony\Bundle\SecurityBundle\Security;
|
||||||
|
|
||||||
class TrackCreateUpdateSubscriber implements EventSubscriber
|
#[\Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener(event: Events::prePersist)]
|
||||||
|
#[\Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener(event: Events::preUpdate)]
|
||||||
|
class TrackCreateUpdateSubscriber
|
||||||
{
|
{
|
||||||
public function __construct(private readonly Security $security) {}
|
public function __construct(private readonly Security $security) {}
|
||||||
|
|
||||||
public function getSubscribedEvents(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Events::prePersist,
|
|
||||||
Events::preUpdate,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function prePersist(PrePersistEventArgs $args): void
|
public function prePersist(PrePersistEventArgs $args): void
|
||||||
{
|
{
|
||||||
$object = $args->getObject();
|
$object = $args->getObject();
|
||||||
|
|||||||
@@ -60,9 +60,7 @@ class DateIntervalType extends AbstractType
|
|||||||
'step' => 1,
|
'step' => 1,
|
||||||
],
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
new GreaterThan([
|
new GreaterThan(value: 0),
|
||||||
'value' => 0,
|
|
||||||
]),
|
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
->add('unit', ChoiceType::class, [
|
->add('unit', ChoiceType::class, [
|
||||||
|
|||||||
@@ -58,37 +58,29 @@ class UserPasswordType extends AbstractType
|
|||||||
],
|
],
|
||||||
'invalid_message' => 'The password fields must match',
|
'invalid_message' => 'The password fields must match',
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
new Length([
|
new Length(min: 14, minMessage: 'The password must be greater than {{ limit }} characters'),
|
||||||
'min' => 14,
|
|
||||||
'minMessage' => 'The password must be greater than {{ limit }} characters',
|
|
||||||
]),
|
|
||||||
new NotBlank(),
|
new NotBlank(),
|
||||||
new Regex([
|
new Regex(pattern: "/((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%!,;:+\"'-\\/{}~=µ\\(\\)£]).{6,})/", message: 'The password must contains one letter, one '
|
||||||
'pattern' => "/((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%!,;:+\"'-\\/{}~=µ\\(\\)£]).{6,})/",
|
.'capitalized letter, one number and one special character '
|
||||||
'message' => 'The password must contains one letter, one '
|
."as *[@#$%!,;:+\"'-/{}~=µ()£]). Other characters are allowed."),
|
||||||
.'capitalized letter, one number and one special character '
|
|
||||||
."as *[@#$%!,;:+\"'-/{}~=µ()£]). Other characters are allowed.",
|
|
||||||
]),
|
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
->add('actual_password', PasswordType::class, [
|
->add('actual_password', PasswordType::class, [
|
||||||
'label' => 'Your actual password',
|
'label' => 'Your actual password',
|
||||||
'mapped' => false,
|
'mapped' => false,
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
new Callback([
|
new Callback(callback: function ($password, ExecutionContextInterface $context, $payload) use ($options) {
|
||||||
'callback' => function ($password, ExecutionContextInterface $context, $payload) use ($options) {
|
if (true === $this->passwordEncoder->isPasswordValid($options['user'], $password)) {
|
||||||
if (true === $this->passwordEncoder->isPasswordValid($options['user'], $password)) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// password problem :-)
|
// password problem :-)
|
||||||
$this->chillLogger
|
$this->chillLogger
|
||||||
->notice('incorrect password when trying to change password', [
|
->notice('incorrect password when trying to change password', [
|
||||||
'username' => $options['user']->getUsername(),
|
'username' => $options['user']->getUsername(),
|
||||||
]);
|
]);
|
||||||
$context->addViolation('Incorrect password');
|
$context->addViolation('Incorrect password');
|
||||||
},
|
}),
|
||||||
]),
|
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,17 +127,11 @@ class UserType extends AbstractType
|
|||||||
],
|
],
|
||||||
'invalid_message' => 'The password fields must match',
|
'invalid_message' => 'The password fields must match',
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
new Length([
|
new Length(min: 9, minMessage: 'The password must be greater than {{ limit }} characters'),
|
||||||
'min' => 9,
|
|
||||||
'minMessage' => 'The password must be greater than {{ limit }} characters',
|
|
||||||
]),
|
|
||||||
new NotBlank(),
|
new NotBlank(),
|
||||||
new Regex([
|
new Regex(pattern: "/((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%!,;:+\"'-\\/{}~=µ\\(\\)£]).{6,})/", message: 'The password must contains one letter, one '
|
||||||
'pattern' => "/((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%!,;:+\"'-\\/{}~=µ\\(\\)£]).{6,})/",
|
.'capitalized letter, one number and one special character '
|
||||||
'message' => 'The password must contains one letter, one '
|
."as *[@#$%!,;:+\"'-/{}~=µ()£]). Other characters are allowed."),
|
||||||
.'capitalized letter, one number and one special character '
|
|
||||||
."as *[@#$%!,;:+\"'-/{}~=µ()£]). Other characters are allowed.",
|
|
||||||
]),
|
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -11,22 +11,13 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\MainBundle\Phonenumber;
|
namespace Chill\MainBundle\Phonenumber;
|
||||||
|
|
||||||
use Twig\Extension\AbstractExtension;
|
class Templating
|
||||||
use Twig\TwigFilter;
|
|
||||||
|
|
||||||
class Templating extends AbstractExtension
|
|
||||||
{
|
{
|
||||||
public function __construct(protected PhonenumberHelper $phonenumberHelper) {}
|
public function __construct(protected PhonenumberHelper $phonenumberHelper) {}
|
||||||
|
|
||||||
|
#[\Twig\Attribute\AsTwigFilter('chill_format_phonenumber')]
|
||||||
public function formatPhonenumber($phonenumber)
|
public function formatPhonenumber($phonenumber)
|
||||||
{
|
{
|
||||||
return $this->phonenumberHelper->format($phonenumber) ?? $phonenumber;
|
return $this->phonenumberHelper->format($phonenumber) ?? $phonenumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFilters()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
new TwigFilter('chill_format_phonenumber', $this->formatPhonenumber(...)),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
|||||||
* @method Location|null findOneBy(array $criteria, array $orderBy = null)
|
* @method Location|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
* @method Location[] findAll()
|
* @method Location[] findAll()
|
||||||
* @method Location[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
* @method Location[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\MainBundle\Entity\Location>
|
||||||
*/
|
*/
|
||||||
class LocationRepository extends ServiceEntityRepository
|
class LocationRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
|||||||
* @method LocationType|null findOneBy(array $criteria, array $orderBy = null)
|
* @method LocationType|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
* @method LocationType[] findAll()
|
* @method LocationType[] findAll()
|
||||||
* @method LocationType[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
* @method LocationType[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\MainBundle\Entity\LocationType>
|
||||||
*/
|
*/
|
||||||
class LocationTypeRepository extends ServiceEntityRepository
|
class LocationTypeRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @template-extends ServiceEntityRepository<EntityWorkflowStepHold>
|
* @template-extends ServiceEntityRepository<EntityWorkflowStepHold>
|
||||||
|
*
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\MainBundle\Entity\Workflow\EntityWorkflowStepHold>
|
||||||
*/
|
*/
|
||||||
class EntityWorkflowStepHoldRepository extends ServiceEntityRepository
|
class EntityWorkflowStepHoldRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @template-extends ServiceEntityRepository<EntityWorkflowStepSignature>
|
* @template-extends ServiceEntityRepository<EntityWorkflowStepSignature>
|
||||||
|
*
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature>
|
||||||
*/
|
*/
|
||||||
class EntityWorkflowStepSignatureRepository extends ServiceEntityRepository
|
class EntityWorkflowStepSignatureRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class ChillExportVoter extends Voter implements ProvideRoleHierarchyInterface
|
|||||||
return $this->helper->supports($attribute, $subject);
|
return $this->helper->supports($attribute, $subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
return $this->helper->voteOnAttribute($attribute, $subject, $token);
|
return $this->helper->voteOnAttribute($attribute, $subject, $token);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ final class EntityWorkflowAttachmentVoter extends Voter
|
|||||||
return $subject instanceof EntityWorkflow && self::EDIT === $attribute;
|
return $subject instanceof EntityWorkflow && self::EDIT === $attribute;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
|
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
if (!$subject instanceof EntityWorkflow) {
|
if (!$subject instanceof EntityWorkflow) {
|
||||||
throw new \UnexpectedValueException('Subject must be an instance of EntityWorkflow');
|
throw new \UnexpectedValueException('Subject must be an instance of EntityWorkflow');
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ final class EntityWorkflowStepSignatureVoter extends Voter
|
|||||||
&& in_array($attribute, [self::SIGN, self::CANCEL, self::REJECT], true);
|
&& in_array($attribute, [self::SIGN, self::CANCEL, self::REJECT], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
|
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
/** @var EntityWorkflowStepSignature $subject */
|
/** @var EntityWorkflowStepSignature $subject */
|
||||||
if ($subject->getSigner() instanceof Person) {
|
if ($subject->getSigner() instanceof Person) {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ final class EntityWorkflowTransitionVoter extends Voter implements ProvideRoleHi
|
|||||||
return self::APPLY_ALL_TRANSITIONS === $attribute && ($subject instanceof EntityWorkflowStep || $subject instanceof EntityWorkflow);
|
return self::APPLY_ALL_TRANSITIONS === $attribute && ($subject instanceof EntityWorkflowStep || $subject instanceof EntityWorkflow);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
|
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
/** @var EntityWorkflowStep|EntityWorkflow $subject */
|
/** @var EntityWorkflowStep|EntityWorkflow $subject */
|
||||||
$entityWorkflow = $subject instanceof EntityWorkflowStep ? $subject->getEntityWorkflow() : $subject;
|
$entityWorkflow = $subject instanceof EntityWorkflowStep ? $subject->getEntityWorkflow() : $subject;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class EntityWorkflowVoter extends Voter
|
|||||||
/**
|
/**
|
||||||
* @param EntityWorkflow $subject
|
* @param EntityWorkflow $subject
|
||||||
*/
|
*/
|
||||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
switch ($attribute) {
|
switch ($attribute) {
|
||||||
case self::CREATE:
|
case self::CREATE:
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class ExportGenerationVoter extends Voter
|
|||||||
return self::VIEW === $attribute && $subject instanceof ExportGeneration;
|
return self::VIEW === $attribute && $subject instanceof ExportGeneration;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
|
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
/* @var ExportGeneration $subject */
|
/* @var ExportGeneration $subject */
|
||||||
return $token->getUser()->getUserIdentifier() === $subject->getCreatedBy()->getUserIdentifier();
|
return $token->getUser()->getUserIdentifier() === $subject->getCreatedBy()->getUserIdentifier();
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ final class NotificationVoter extends Voter
|
|||||||
/**
|
/**
|
||||||
* @param string $attribute
|
* @param string $attribute
|
||||||
*/
|
*/
|
||||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
$user = $token->getUser();
|
$user = $token->getUser();
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ final class SavedExportVoter extends Voter
|
|||||||
return $subject instanceof SavedExport && \in_array($attribute, self::ALL, true);
|
return $subject instanceof SavedExport && \in_array($attribute, self::ALL, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
/* @var SavedExport $subject */
|
/* @var SavedExport $subject */
|
||||||
$user = $token->getUser();
|
$user = $token->getUser();
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ final class UserGroupVoter extends Voter
|
|||||||
return self::APPEND_TO_GROUP === $attribute && $subject instanceof UserGroup;
|
return self::APPEND_TO_GROUP === $attribute && $subject instanceof UserGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
|
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
/* @var UserGroup $subject */
|
/* @var UserGroup $subject */
|
||||||
if ($this->security->isGranted('ROLE_ADMIN')) {
|
if ($this->security->isGranted('ROLE_ADMIN')) {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class WorkflowEntityDeletionVoter extends Voter
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
foreach ($this->handlers as $handler) {
|
foreach ($this->handlers as $handler) {
|
||||||
if ($handler->isObjectSupported($subject)) {
|
if ($handler->isObjectSupported($subject)) {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class PasswordRecoverVoter extends Voter
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
switch ($attribute) {
|
switch ($attribute) {
|
||||||
case self::TRY_TOKEN:
|
case self::TRY_TOKEN:
|
||||||
|
|||||||
@@ -11,21 +11,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\MainBundle\Security\Resolver;
|
namespace Chill\MainBundle\Security\Resolver;
|
||||||
|
|
||||||
use Twig\TwigFilter;
|
final class ResolverTwigExtension
|
||||||
|
|
||||||
final class ResolverTwigExtension extends \Twig\Extension\AbstractExtension
|
|
||||||
{
|
{
|
||||||
public function __construct(private readonly CenterResolverManagerInterface $centerResolverDispatcher, private readonly ScopeResolverDispatcher $scopeResolverDispatcher) {}
|
public function __construct(private readonly CenterResolverManagerInterface $centerResolverDispatcher, private readonly ScopeResolverDispatcher $scopeResolverDispatcher) {}
|
||||||
|
|
||||||
public function getFilters()
|
#[\Twig\Attribute\AsTwigFilter('chill_is_scope_concerned')]
|
||||||
{
|
|
||||||
return [
|
|
||||||
new TwigFilter('chill_resolve_center', $this->resolveCenter(...)),
|
|
||||||
new TwigFilter('chill_resolve_scope', $this->resolveScope(...)),
|
|
||||||
new TwigFilter('chill_is_scope_concerned', $this->isScopeConcerned(...)),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isScopeConcerned($entity, ?array $options = []): bool
|
public function isScopeConcerned($entity, ?array $options = []): bool
|
||||||
{
|
{
|
||||||
return $this->scopeResolverDispatcher->isConcerned($entity, $options);
|
return $this->scopeResolverDispatcher->isConcerned($entity, $options);
|
||||||
@@ -34,6 +24,7 @@ final class ResolverTwigExtension extends \Twig\Extension\AbstractExtension
|
|||||||
/**
|
/**
|
||||||
* @return Center|Center[]|null
|
* @return Center|Center[]|null
|
||||||
*/
|
*/
|
||||||
|
#[\Twig\Attribute\AsTwigFilter('chill_resolve_center')]
|
||||||
public function resolveCenter(mixed $entity, ?array $options = []): array
|
public function resolveCenter(mixed $entity, ?array $options = []): array
|
||||||
{
|
{
|
||||||
return $this->centerResolverDispatcher->resolveCenters($entity, $options);
|
return $this->centerResolverDispatcher->resolveCenters($entity, $options);
|
||||||
@@ -42,6 +33,7 @@ final class ResolverTwigExtension extends \Twig\Extension\AbstractExtension
|
|||||||
/**
|
/**
|
||||||
* @return array|\Chill\MainBundle\Entity\Scope|\Chill\MainBundle\Entity\Scope[]
|
* @return array|\Chill\MainBundle\Entity\Scope|\Chill\MainBundle\Entity\Scope[]
|
||||||
*/
|
*/
|
||||||
|
#[\Twig\Attribute\AsTwigFilter('chill_resolve_scope')]
|
||||||
public function resolveScope($entity, ?array $options = []): array|\Chill\MainBundle\Entity\Scope
|
public function resolveScope($entity, ?array $options = []): array|\Chill\MainBundle\Entity\Scope
|
||||||
{
|
{
|
||||||
return $this->scopeResolverDispatcher->resolveScope();
|
return $this->scopeResolverDispatcher->resolveScope();
|
||||||
|
|||||||
@@ -13,9 +13,7 @@ namespace Chill\MainBundle\Templating;
|
|||||||
|
|
||||||
use Symfony\Bridge\Twig\Extension\RoutingExtension;
|
use Symfony\Bridge\Twig\Extension\RoutingExtension;
|
||||||
use Symfony\Component\HttpFoundation\RequestStack;
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
use Twig\Extension\AbstractExtension;
|
|
||||||
use Twig\Node\Node;
|
use Twig\Node\Node;
|
||||||
use Twig\TwigFilter;
|
|
||||||
use Twig\TwigFunction;
|
use Twig\TwigFunction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,7 +21,7 @@ use Twig\TwigFunction;
|
|||||||
*
|
*
|
||||||
* The logic of the function is based on the original routing extension.
|
* The logic of the function is based on the original routing extension.
|
||||||
*/
|
*/
|
||||||
class ChillTwigRoutingHelper extends AbstractExtension
|
class ChillTwigRoutingHelper
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var RoutingExtension
|
* @var RoutingExtension
|
||||||
@@ -43,13 +41,6 @@ class ChillTwigRoutingHelper extends AbstractExtension
|
|||||||
$this->originalExtension = $originalExtension;
|
$this->originalExtension = $originalExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFilters()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
new TwigFilter('chill_return_path_label', $this->getLabelReturnPath(...)),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFunctions()
|
public function getFunctions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@@ -82,6 +73,7 @@ class ChillTwigRoutingHelper extends AbstractExtension
|
|||||||
return $this->originalExtension->getPath($name, $params, $relative);
|
return $this->originalExtension->getPath($name, $params, $relative);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[\Twig\Attribute\AsTwigFilter('chill_return_path_label')]
|
||||||
public function getLabelReturnPath($default)
|
public function getLabelReturnPath($default)
|
||||||
{
|
{
|
||||||
$request = $this->requestStack->getCurrentRequest();
|
$request = $this->requestStack->getCurrentRequest();
|
||||||
|
|||||||
@@ -12,31 +12,15 @@ declare(strict_types=1);
|
|||||||
namespace Chill\MainBundle\Templating;
|
namespace Chill\MainBundle\Templating;
|
||||||
|
|
||||||
use Twig\Extension\AbstractExtension;
|
use Twig\Extension\AbstractExtension;
|
||||||
use Twig\TwigFilter;
|
use Twig\Extension\ExtensionInterface;
|
||||||
|
|
||||||
class TranslatableStringTwig extends AbstractExtension
|
class TranslatableStringTwig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* TranslatableStringTwig constructor.
|
* TranslatableStringTwig constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct(private readonly TranslatableStringHelper $helper) {}
|
public function __construct(private readonly TranslatableStringHelper $helper) {}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of filters to add to the existing list.
|
|
||||||
*
|
|
||||||
* (non-PHPdoc)
|
|
||||||
*
|
|
||||||
* @see Twig_Extension::getFilters()
|
|
||||||
*/
|
|
||||||
public function getFilters()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
new TwigFilter(
|
|
||||||
'localize_translatable_string',
|
|
||||||
$this->localize(...)
|
|
||||||
), ];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the extension.
|
* Returns the name of the extension.
|
||||||
*/
|
*/
|
||||||
@@ -45,6 +29,7 @@ class TranslatableStringTwig extends AbstractExtension
|
|||||||
return 'chill_main_localize';
|
return 'chill_main_localize';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[\Twig\Attribute\AsTwigFilter('localize_translatable_string')]
|
||||||
public function localize(array $translatableStrings): ?string
|
public function localize(array $translatableStrings): ?string
|
||||||
{
|
{
|
||||||
return $this->helper
|
return $this->helper
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ final class ChillPersonMoveCommand extends Command
|
|||||||
private readonly EntityManagerInterface $em,
|
private readonly EntityManagerInterface $em,
|
||||||
private readonly LoggerInterface $chillLogger,
|
private readonly LoggerInterface $chillLogger,
|
||||||
) {
|
) {
|
||||||
parent::__construct('chill:person:move');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function buildLoggingContext(Person $from, Person $to, $deleteEntities, $sqls)
|
protected function buildLoggingContext(Person $from, Person $to, $deleteEntities, $sqls)
|
||||||
|
|||||||
@@ -14,39 +14,32 @@ namespace Chill\PersonBundle\Command;
|
|||||||
use Chill\PersonBundle\Service\Import\SocialWorkMetadataInterface;
|
use Chill\PersonBundle\Service\Import\SocialWorkMetadataInterface;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use League\Csv\Reader;
|
use League\Csv\Reader;
|
||||||
use Symfony\Component\Console\Command\Command;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
|
||||||
|
|
||||||
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:person:import-socialwork')]
|
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:person:import-socialwork')]
|
||||||
final class ImportSocialWorkMetadata extends Command
|
final class ImportSocialWorkMetadata
|
||||||
{
|
{
|
||||||
protected EntityManagerInterface $em;
|
private EntityManagerInterface $em;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected SocialWorkMetadataInterface $importer,
|
private SocialWorkMetadataInterface $importer,
|
||||||
) {
|
) {
|
||||||
parent::__construct('chill:person:import-socialwork');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure(): void
|
private function configure(): void
|
||||||
{
|
{
|
||||||
$description = 'Imports a structured table containing social issues, social actions, objectives, results and evaluations.';
|
$description = 'Imports a structured table containing social issues, social actions, objectives, results and evaluations.';
|
||||||
$help = 'File to csv format, no headers, semi-colon as delimiter, datas sorted by alphabetical order, column after column.'.PHP_EOL
|
$help = 'File to csv format, no headers, semi-colon as delimiter, datas sorted by alphabetical order, column after column.'.PHP_EOL
|
||||||
.'Columns are: social issues parent, social issues child, social actions parent, social actions child, goals, results, evaluations.'.PHP_EOL
|
.'Columns are: social issues parent, social issues child, social actions parent, social actions child, goals, results, evaluations.'.PHP_EOL
|
||||||
.PHP_EOL
|
.PHP_EOL
|
||||||
.'See social_work_metadata.csv as example.'.PHP_EOL;
|
.'See social_work_metadata.csv as example.'.PHP_EOL;
|
||||||
|
|
||||||
$this
|
|
||||||
->addOption('filepath', 'f', InputOption::VALUE_REQUIRED, 'The file to import.')
|
|
||||||
->addOption('language', 'l', InputOption::VALUE_OPTIONAL, 'The default language')
|
|
||||||
->setHelp($help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
public function __invoke(#[\Symfony\Component\Console\Attribute\Option(name: 'filepath', shortcut: 'f', mode: InputOption::VALUE_REQUIRED, description: 'The file to import.')]
|
||||||
|
$filepath, #[\Symfony\Component\Console\Attribute\Option(name: 'language', shortcut: 'l', mode: InputOption::VALUE_OPTIONAL, description: 'The default language')]
|
||||||
|
$language): int
|
||||||
{
|
{
|
||||||
$filepath = $input->getOption('filepath');
|
$filepath = $filepath;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$csv = Reader::from($filepath);
|
$csv = Reader::from($filepath);
|
||||||
|
|||||||
@@ -14,42 +14,31 @@ namespace Chill\PersonBundle\Command;
|
|||||||
use Chill\PersonBundle\Service\AccompanyingPeriod\OldDraftAccompanyingPeriodRemoverInterface;
|
use Chill\PersonBundle\Service\AccompanyingPeriod\OldDraftAccompanyingPeriodRemoverInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
|
||||||
|
|
||||||
#[\Symfony\Component\Console\Attribute\AsCommand(name:'chill:person:remove-old-draft-period')]
|
#[\Symfony\Component\Console\Attribute\AsCommand(name:'chill:person:remove-old-draft-period')]
|
||||||
class RemoveOldDraftAccompanyingPeriodCommand extends Command
|
class RemoveOldDraftAccompanyingPeriodCommand
|
||||||
{
|
{
|
||||||
protected static $defaultDescription = 'Remove draft accompanying period which are still draft and unused';
|
protected static $defaultDescription = 'Remove draft accompanying period which are still draft and unused';
|
||||||
|
|
||||||
public function __construct(private readonly LoggerInterface $logger, private readonly OldDraftAccompanyingPeriodRemoverInterface $remover)
|
public function __construct(private readonly LoggerInterface $logger, private readonly OldDraftAccompanyingPeriodRemoverInterface $remover)
|
||||||
{
|
{
|
||||||
parent::__construct('chill:person:remove-old-draft-period');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure(): void
|
public function __invoke(
|
||||||
{
|
#[\Symfony\Component\Console\Attribute\Argument(name: 'interval', description: 'The interval for unactive periods')]
|
||||||
$this
|
?string $interval = 'P15D',
|
||||||
->addArgument('interval', InputArgument::OPTIONAL, 'The interval for unactive periods', 'P15D');
|
): int {
|
||||||
}
|
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
||||||
{
|
|
||||||
$this->logger->info('['.$this->getName().'] started', [
|
$this->logger->info('['.$this->getName().'] started', [
|
||||||
'interval' => $input->getArgument('interval'),
|
'interval' => $interval,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$interval = new \DateInterval($input->getArgument('interval'));
|
$interval = new \DateInterval($interval);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->error('['.$this->getName().'] bad interval');
|
$this->logger->error('['.$this->getName().'] bad interval');
|
||||||
|
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->remover->remove($interval);
|
$this->remover->remove($interval);
|
||||||
|
|
||||||
$this->logger->info('['.$this->getName().'] end of command');
|
$this->logger->info('['.$this->getName().'] end of command');
|
||||||
|
|
||||||
return Command::SUCCESS;
|
return Command::SUCCESS;
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
|||||||
$builder = $this->formFactory->createNamedBuilder('reassign', FormType::class, $defaultData);
|
$builder = $this->formFactory->createNamedBuilder('reassign', FormType::class, $defaultData);
|
||||||
|
|
||||||
if (null !== $userFrom) {
|
if (null !== $userFrom) {
|
||||||
$constraints = [new NotIdenticalTo(['value' => $userFrom])];
|
$constraints = [new NotIdenticalTo(value: $userFrom)];
|
||||||
} else {
|
} else {
|
||||||
$constraints = [];
|
$constraints = [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,11 +99,7 @@ class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
->setParameters([
|
->setParameters(new \Doctrine\Common\Collections\ArrayCollection([new \Doctrine\ORM\Query\Parameter('user', $user), new \Doctrine\ORM\Query\Parameter('now', new \DateTimeImmutable('now')), new \Doctrine\ORM\Query\Parameter('closed', AccompanyingPeriod::STEP_CLOSED)]));
|
||||||
'user' => $user,
|
|
||||||
'now' => new \DateTimeImmutable('now'),
|
|
||||||
'closed' => AccompanyingPeriod::STEP_CLOSED,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $qb;
|
return $qb;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,11 +253,7 @@ class AccompanyingPeriodWorkRepository implements ObjectRepository
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
->setParameters([
|
->setParameters(new \Doctrine\Common\Collections\ArrayCollection([new \Doctrine\ORM\Query\Parameter('user', $user), new \Doctrine\ORM\Query\Parameter('since', $since), new \Doctrine\ORM\Query\Parameter('until', $until)]));
|
||||||
'user' => $user,
|
|
||||||
'since' => $since,
|
|
||||||
'until' => $until,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $qb;
|
return $qb;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ use Chill\PersonBundle\Entity\AdministrativeStatus;
|
|||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\PersonBundle\Entity\AdministrativeStatus>
|
||||||
|
*/
|
||||||
class AdministrativeStatusRepository extends ServiceEntityRepository
|
class AdministrativeStatusRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
public function __construct(ManagerRegistry $registry)
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ use Chill\PersonBundle\Entity\EmploymentStatus;
|
|||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\PersonBundle\Entity\EmploymentStatus>
|
||||||
|
*/
|
||||||
class EmploymentStatusRepository extends ServiceEntityRepository
|
class EmploymentStatusRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
public function __construct(ManagerRegistry $registry)
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @template-extends ServiceEntityRepository<PersonIdentifierDefinition>
|
* @template-extends ServiceEntityRepository<PersonIdentifierDefinition>
|
||||||
|
*
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\PersonBundle\Entity\Identifier\PersonIdentifierDefinition>
|
||||||
*/
|
*/
|
||||||
class PersonIdentifierDefinitionRepository extends ServiceEntityRepository
|
class PersonIdentifierDefinitionRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
|||||||
* @method ResidentialAddress|null findOneBy(array $criteria, array $orderBy = null)
|
* @method ResidentialAddress|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
* @method ResidentialAddress[] findAll()
|
* @method ResidentialAddress[] findAll()
|
||||||
* @method ResidentialAddress[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
* @method ResidentialAddress[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\PersonBundle\Entity\Person\ResidentialAddress>
|
||||||
*/
|
*/
|
||||||
class ResidentialAddressRepository extends ServiceEntityRepository
|
class ResidentialAddressRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class AccompanyingPeriodCommentVoter extends Voter
|
|||||||
return $subject instanceof Comment;
|
return $subject instanceof Comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
return match ($attribute) {
|
return match ($attribute) {
|
||||||
self::EDIT => $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod()),
|
self::EDIT => $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod()),
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class AccompanyingPeriodResourceVoter extends Voter
|
|||||||
return $subject instanceof Resource && self::EDIT === $attribute;
|
return $subject instanceof Resource && self::EDIT === $attribute;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
return match ($attribute) {
|
return match ($attribute) {
|
||||||
self::EDIT => $this->accessDecisionManager->decide(
|
self::EDIT => $this->accessDecisionManager->decide(
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class AccompanyingPeriodWorkEvaluationDocumentVoter extends Voter
|
|||||||
*
|
*
|
||||||
* @return bool|void
|
* @return bool|void
|
||||||
*/
|
*/
|
||||||
public function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
public function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
return match ($attribute) {
|
return match ($attribute) {
|
||||||
self::SEE => $this->accessDecisionManager->decide(
|
self::SEE => $this->accessDecisionManager->decide(
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class AccompanyingPeriodWorkEvaluationVoter extends Voter implements ChillVoterI
|
|||||||
* @param string $attribute
|
* @param string $attribute
|
||||||
* @param AccompanyingPeriodWorkEvaluation $subject
|
* @param AccompanyingPeriodWorkEvaluation $subject
|
||||||
*/
|
*/
|
||||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
return match ($attribute) {
|
return match ($attribute) {
|
||||||
self::STATS => $this->security->isGranted(AccompanyingPeriodVoter::STATS, $subject),
|
self::STATS => $this->security->isGranted(AccompanyingPeriodVoter::STATS, $subject),
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class AccompanyingPeriodWorkVoter extends Voter implements ProvideRoleHierarchyI
|
|||||||
* @param string $attribute
|
* @param string $attribute
|
||||||
* @param AccompanyingPeriodWork $subject
|
* @param AccompanyingPeriodWork $subject
|
||||||
*/
|
*/
|
||||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
if ($subject instanceof AccompanyingPeriodWork) {
|
if ($subject instanceof AccompanyingPeriodWork) {
|
||||||
return match ($attribute) {
|
return match ($attribute) {
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, Chi
|
|||||||
|| $this->helper->supports($attribute, $subject);
|
|| $this->helper->supports($attribute, $subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||||
{
|
{
|
||||||
return match ($attribute) {
|
return match ($attribute) {
|
||||||
self::SEE => $this->checkAssociatedMembersRole($subject, PersonVoter::SEE),
|
self::SEE => $this->checkAssociatedMembersRole($subject, PersonVoter::SEE),
|
||||||
|
|||||||
@@ -85,15 +85,13 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
|
|||||||
default => $label.
|
default => $label.
|
||||||
' ('.$this->translator->trans("Report's question").')',
|
' ('.$this->translator->trans("Report's question").')',
|
||||||
},
|
},
|
||||||
'constraints' => [new Callback([
|
'constraints' => [new Callback(callback: static function ($selected, ExecutionContextInterface $context) {
|
||||||
'callback' => static function ($selected, ExecutionContextInterface $context) {
|
if (0 === \count($selected)) {
|
||||||
if (0 === \count($selected)) {
|
$context->buildViolation('You must select at least one element')
|
||||||
$context->buildViolation('You must select at least one element')
|
->atPath('fields')
|
||||||
->atPath('fields')
|
->addViolation();
|
||||||
->addViolation();
|
}
|
||||||
}
|
})],
|
||||||
},
|
|
||||||
])],
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$builder->add('address_date', ChillDateType::class, [
|
$builder->add('address_date', ChillDateType::class, [
|
||||||
|
|||||||
@@ -13,10 +13,8 @@ namespace Chill\TaskBundle\Templating;
|
|||||||
|
|
||||||
use Chill\TaskBundle\Entity\AbstractTask;
|
use Chill\TaskBundle\Entity\AbstractTask;
|
||||||
use Chill\TaskBundle\Workflow\TaskWorkflowManager;
|
use Chill\TaskBundle\Workflow\TaskWorkflowManager;
|
||||||
use Twig\Extension\AbstractExtension;
|
|
||||||
use Twig\TwigFunction;
|
|
||||||
|
|
||||||
class TaskTwigExtension extends AbstractExtension
|
class TaskTwigExtension
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var TaskWorkflowManager
|
* @var TaskWorkflowManager
|
||||||
@@ -28,13 +26,7 @@ class TaskTwigExtension extends AbstractExtension
|
|||||||
$this->taskWorkflowManager = $taskWorkflowManager;
|
$this->taskWorkflowManager = $taskWorkflowManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFunctions()
|
#[\Twig\Attribute\AsTwigFunction('task_workflow_metadata')]
|
||||||
{
|
|
||||||
return [
|
|
||||||
new TwigFunction('task_workflow_metadata', $this->getWorkflowMetadata(...)),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getWorkflowMetadata(
|
public function getWorkflowMetadata(
|
||||||
AbstractTask $task,
|
AbstractTask $task,
|
||||||
string $key,
|
string $key,
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
|||||||
* @method ThirdPartyCategory|null findOneBy(array $criteria, array $orderBy = null)
|
* @method ThirdPartyCategory|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
* @method ThirdPartyCategory[] findAll()
|
* @method ThirdPartyCategory[] findAll()
|
||||||
* @method ThirdPartyCategory[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
* @method ThirdPartyCategory[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\ThirdPartyBundle\Entity\ThirdPartyCategory>
|
||||||
*/
|
*/
|
||||||
class ThirdPartyCategoryRepository extends ServiceEntityRepository
|
class ThirdPartyCategoryRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
|||||||
* @method ThirdPartyProfession|null findOneBy(array $criteria, array $orderBy = null)
|
* @method ThirdPartyProfession|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
* @method ThirdPartyProfession[] findAll()
|
* @method ThirdPartyProfession[] findAll()
|
||||||
* @method ThirdPartyProfession[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
* @method ThirdPartyProfession[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*
|
||||||
|
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\ThirdPartyBundle\Entity\ThirdPartyProfession>
|
||||||
*/
|
*/
|
||||||
class ThirdPartyProfessionRepository extends ServiceEntityRepository
|
class ThirdPartyProfessionRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user