mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-03-02 03:59:40 +00:00
apply rector rules
This commit is contained in:
@@ -31,7 +31,6 @@ final class ChillPersonMoveCommand extends Command
|
||||
private readonly EntityManagerInterface $em,
|
||||
private readonly LoggerInterface $chillLogger,
|
||||
) {
|
||||
parent::__construct('chill:person:move');
|
||||
}
|
||||
|
||||
protected function buildLoggingContext(Person $from, Person $to, $deleteEntities, $sqls)
|
||||
|
||||
@@ -14,39 +14,32 @@ namespace Chill\PersonBundle\Command;
|
||||
use Chill\PersonBundle\Service\Import\SocialWorkMetadataInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
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\Output\OutputInterface;
|
||||
|
||||
#[\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(
|
||||
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.';
|
||||
$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
|
||||
.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 {
|
||||
$csv = Reader::from($filepath);
|
||||
|
||||
@@ -14,42 +14,31 @@ namespace Chill\PersonBundle\Command;
|
||||
use Chill\PersonBundle\Service\AccompanyingPeriod\OldDraftAccompanyingPeriodRemoverInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
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')]
|
||||
class RemoveOldDraftAccompanyingPeriodCommand extends Command
|
||||
class RemoveOldDraftAccompanyingPeriodCommand
|
||||
{
|
||||
protected static $defaultDescription = 'Remove draft accompanying period which are still draft and unused';
|
||||
|
||||
public function __construct(private readonly LoggerInterface $logger, private readonly OldDraftAccompanyingPeriodRemoverInterface $remover)
|
||||
{
|
||||
parent::__construct('chill:person:remove-old-draft-period');
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
$this
|
||||
->addArgument('interval', InputArgument::OPTIONAL, 'The interval for unactive periods', 'P15D');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
public function __invoke(
|
||||
#[\Symfony\Component\Console\Attribute\Argument(name: 'interval', description: 'The interval for unactive periods')]
|
||||
?string $interval = 'P15D',
|
||||
): int {
|
||||
$this->logger->info('['.$this->getName().'] started', [
|
||||
'interval' => $input->getArgument('interval'),
|
||||
'interval' => $interval,
|
||||
]);
|
||||
|
||||
try {
|
||||
$interval = new \DateInterval($input->getArgument('interval'));
|
||||
$interval = new \DateInterval($interval);
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error('['.$this->getName().'] bad interval');
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$this->remover->remove($interval);
|
||||
|
||||
$this->logger->info('['.$this->getName().'] end of command');
|
||||
|
||||
return Command::SUCCESS;
|
||||
|
||||
@@ -148,7 +148,7 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
||||
$builder = $this->formFactory->createNamedBuilder('reassign', FormType::class, $defaultData);
|
||||
|
||||
if (null !== $userFrom) {
|
||||
$constraints = [new NotIdenticalTo(['value' => $userFrom])];
|
||||
$constraints = [new NotIdenticalTo(value: $userFrom)];
|
||||
} else {
|
||||
$constraints = [];
|
||||
}
|
||||
|
||||
@@ -99,11 +99,7 @@ class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository
|
||||
)
|
||||
)
|
||||
)
|
||||
->setParameters([
|
||||
'user' => $user,
|
||||
'now' => new \DateTimeImmutable('now'),
|
||||
'closed' => AccompanyingPeriod::STEP_CLOSED,
|
||||
]);
|
||||
->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)]));
|
||||
|
||||
return $qb;
|
||||
}
|
||||
|
||||
@@ -253,11 +253,7 @@ class AccompanyingPeriodWorkRepository implements ObjectRepository
|
||||
)
|
||||
)
|
||||
)
|
||||
->setParameters([
|
||||
'user' => $user,
|
||||
'since' => $since,
|
||||
'until' => $until,
|
||||
]);
|
||||
->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)]));
|
||||
|
||||
return $qb;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ use Chill\PersonBundle\Entity\AdministrativeStatus;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\PersonBundle\Entity\AdministrativeStatus>
|
||||
*/
|
||||
class AdministrativeStatusRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
|
||||
@@ -15,6 +15,9 @@ use Chill\PersonBundle\Entity\EmploymentStatus;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\PersonBundle\Entity\EmploymentStatus>
|
||||
*/
|
||||
class EmploymentStatusRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
|
||||
@@ -17,6 +17,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @template-extends ServiceEntityRepository<PersonIdentifierDefinition>
|
||||
*
|
||||
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\PersonBundle\Entity\Identifier\PersonIdentifierDefinition>
|
||||
*/
|
||||
class PersonIdentifierDefinitionRepository extends ServiceEntityRepository
|
||||
{
|
||||
|
||||
@@ -23,6 +23,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
||||
* @method ResidentialAddress|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method ResidentialAddress[] findAll()
|
||||
* @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
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ class AccompanyingPeriodCommentVoter extends Voter
|
||||
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) {
|
||||
self::EDIT => $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod()),
|
||||
|
||||
@@ -27,7 +27,7 @@ class AccompanyingPeriodResourceVoter extends Voter
|
||||
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) {
|
||||
self::EDIT => $this->accessDecisionManager->decide(
|
||||
|
||||
@@ -40,7 +40,7 @@ class AccompanyingPeriodWorkEvaluationDocumentVoter extends Voter
|
||||
*
|
||||
* @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) {
|
||||
self::SEE => $this->accessDecisionManager->decide(
|
||||
|
||||
@@ -43,7 +43,7 @@ class AccompanyingPeriodWorkEvaluationVoter extends Voter implements ChillVoterI
|
||||
* @param string $attribute
|
||||
* @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) {
|
||||
self::STATS => $this->security->isGranted(AccompanyingPeriodVoter::STATS, $subject),
|
||||
|
||||
@@ -89,7 +89,7 @@ class AccompanyingPeriodWorkVoter extends Voter implements ProvideRoleHierarchyI
|
||||
* @param string $attribute
|
||||
* @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) {
|
||||
return match ($attribute) {
|
||||
|
||||
@@ -73,7 +73,7 @@ class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, Chi
|
||||
|| $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) {
|
||||
self::SEE => $this->checkAssociatedMembersRole($subject, PersonVoter::SEE),
|
||||
|
||||
Reference in New Issue
Block a user