mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-30 19:43:49 +00:00
Apply rector rules: symfony up to 54
This commit is contained in:
@@ -27,12 +27,12 @@ use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Question\ChoiceQuestion;
|
||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
||||
use Symfony\Component\Validator\ConstraintViolationListInterface;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
|
||||
class ChillImportUsersCommand extends Command
|
||||
{
|
||||
protected static $defaultDescription = 'Import users from csv file';
|
||||
/**
|
||||
* Centers and aliases.
|
||||
*
|
||||
@@ -55,7 +55,7 @@ class ChillImportUsersCommand extends Command
|
||||
public function __construct(
|
||||
protected EntityManagerInterface $em,
|
||||
protected LoggerInterface $logger,
|
||||
protected UserPasswordEncoderInterface $passwordEncoder,
|
||||
protected \Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface $passwordEncoder,
|
||||
protected ValidatorInterface $validator,
|
||||
protected UserRepository $userRepository
|
||||
) {
|
||||
@@ -86,7 +86,6 @@ class ChillImportUsersCommand extends Command
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setDescription('Import users from csv file')
|
||||
->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')
|
||||
@@ -130,7 +129,7 @@ class ChillImportUsersCommand extends Command
|
||||
->setEmail(\trim((string) $data['email']))
|
||||
->setUsername(\trim((string) $data['username']))
|
||||
->setEnabled(true)
|
||||
->setPassword($this->passwordEncoder->encodePassword(
|
||||
->setPassword($this->passwordEncoder->hashPassword(
|
||||
$user,
|
||||
\bin2hex(\random_bytes(32))
|
||||
));
|
||||
@@ -207,7 +206,7 @@ class ChillImportUsersCommand extends Command
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -29,6 +29,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
*/
|
||||
class ChillUserSendRenewPasswordCodeCommand extends Command
|
||||
{
|
||||
protected static $defaultDescription = 'Send a message with code to recover password';
|
||||
/**
|
||||
* @var EntityManagerInterface
|
||||
*/
|
||||
@@ -82,7 +83,6 @@ class ChillUserSendRenewPasswordCodeCommand extends Command
|
||||
{
|
||||
$this
|
||||
->setName('chill:user:send-password-recover-code')
|
||||
->setDescription('Send a message with code to recover password')
|
||||
->addArgument('csvfile', InputArgument::REQUIRED, 'CSV file with the list of users')
|
||||
->addOption('template', null, InputOption::VALUE_REQUIRED, 'Template for email')
|
||||
->addOption('expiration', null, InputOption::VALUE_REQUIRED, 'Expiration of the link, as an unix timestamp')
|
||||
@@ -108,7 +108,7 @@ class ChillUserSendRenewPasswordCodeCommand extends Command
|
||||
$this->sendRecoverCode($user);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -19,6 +19,8 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class ExecuteCronJobCommand extends Command
|
||||
{
|
||||
protected static $defaultDescription = 'Execute the cronjob(s) given as argument, or one cronjob scheduled by system.';
|
||||
|
||||
public function __construct(
|
||||
private readonly CronManagerInterface $cronManager
|
||||
) {
|
||||
@@ -28,7 +30,6 @@ class ExecuteCronJobCommand extends Command
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setDescription('Execute the cronjob(s) given as argument, or one cronjob scheduled by system.')
|
||||
->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)', [])
|
||||
->addUsage('');
|
||||
@@ -39,13 +40,13 @@ class ExecuteCronJobCommand extends Command
|
||||
if ([] === $input->getArgument('job')) {
|
||||
$this->cronManager->run();
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
foreach ($input->getArgument('job') as $jobName) {
|
||||
$this->cronManager->run($jobName);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,8 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class LoadAddressesBEFromBestAddressCommand extends Command
|
||||
{
|
||||
protected static $defaultDescription = 'Import BE addresses from BeST Address (see https://osoc19.github.io/best/)';
|
||||
|
||||
public function __construct(
|
||||
private readonly AddressReferenceBEFromBestAddress $addressImporter,
|
||||
private readonly PostalCodeBEFromBestAddress $postalCodeBEFromBestAddressImporter
|
||||
@@ -32,8 +34,7 @@ class LoadAddressesBEFromBestAddressCommand extends Command
|
||||
$this
|
||||
->setName('chill:main:address-ref-from-best-addresses')
|
||||
->addArgument('lang', InputArgument::REQUIRED, "Language code, for example 'fr'")
|
||||
->addArgument('list', InputArgument::IS_ARRAY, "The list to add, for example 'full', or 'extract' (dev) or '1xxx' (brussel CP)")
|
||||
->setDescription('Import BE addresses from BeST Address (see https://osoc19.github.io/best/)');
|
||||
->addArgument('list', InputArgument::IS_ARRAY, "The list to add, for example 'full', or 'extract' (dev) or '1xxx' (brussel CP)");
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
@@ -42,6 +43,6 @@ class LoadAddressesBEFromBestAddressCommand extends Command
|
||||
|
||||
$this->addressImporter->import($input->getArgument('lang'), $input->getArgument('list'));
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@@ -19,6 +19,8 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class LoadAddressesFRFromBANOCommand extends Command
|
||||
{
|
||||
protected static $defaultDescription = 'Import FR addresses from bano (see https://bano.openstreetmap.fr';
|
||||
|
||||
public function __construct(private readonly AddressReferenceFromBano $addressReferenceFromBano)
|
||||
{
|
||||
parent::__construct();
|
||||
@@ -27,8 +29,7 @@ class LoadAddressesFRFromBANOCommand extends Command
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('chill:main:address-ref-from-bano')
|
||||
->addArgument('departementNo', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'a list of departement numbers')
|
||||
->setDescription('Import FR addresses from bano (see https://bano.openstreetmap.fr');
|
||||
->addArgument('departementNo', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'a list of departement numbers');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
@@ -39,6 +40,6 @@ class LoadAddressesFRFromBANOCommand extends Command
|
||||
$this->addressReferenceFromBano->import($departementNo);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@@ -54,8 +54,6 @@ class LoadAndUpdateLanguagesCommand extends Command
|
||||
{
|
||||
$this
|
||||
->setName('chill:main:languages:populate')
|
||||
->setDescription('Load or update languages in db. This command does not delete existing '.
|
||||
'languages, but will update names according to available languages')
|
||||
->addOption(
|
||||
self::INCLUDE_REGIONAL_VERSION,
|
||||
null,
|
||||
@@ -122,6 +120,6 @@ class LoadAndUpdateLanguagesCommand extends Command
|
||||
|
||||
$em->flush();
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@@ -55,9 +55,7 @@ class LoadCountriesCommand extends Command
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('chill:main:countries:populate')
|
||||
->setDescription('Load or update countries in db. This command does not delete existing countries, '.
|
||||
'but will update names according to available languages');
|
||||
$this->setName('chill:main:countries:populate');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,6 +81,6 @@ class LoadCountriesCommand extends Command
|
||||
|
||||
$em->flush();
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@@ -18,6 +18,8 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class LoadPostalCodeFR extends Command
|
||||
{
|
||||
protected static $defaultDescription = 'Load France\'s postal code from online open data';
|
||||
|
||||
public function __construct(private readonly PostalCodeFRFromOpenData $loader)
|
||||
{
|
||||
parent::__construct();
|
||||
@@ -25,14 +27,13 @@ class LoadPostalCodeFR extends Command
|
||||
|
||||
public function configure(): void
|
||||
{
|
||||
$this->setName('chill:main:postal-code:load:FR')
|
||||
->setDescription('Load France\'s postal code from online open data');
|
||||
$this->setName('chill:main:postal-code:load:FR');
|
||||
}
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$this->loader->import();
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@@ -25,6 +25,8 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
|
||||
class LoadPostalCodesCommand extends Command
|
||||
{
|
||||
protected static $defaultDescription = 'Add the postal code from a csv file.';
|
||||
|
||||
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly ValidatorInterface $validator)
|
||||
{
|
||||
parent::__construct();
|
||||
@@ -33,7 +35,6 @@ class LoadPostalCodesCommand extends Command
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('chill:main:postal-code:populate')
|
||||
->setDescription('Add the postal code from a csv file.')
|
||||
->setHelp('This script will try to avoid existing postal code '
|
||||
."using the postal code and name. \n"
|
||||
.'The CSV file must have the following columns: '
|
||||
@@ -101,7 +102,7 @@ class LoadPostalCodesCommand extends Command
|
||||
|
||||
$output->writeln('<info>'.$num.' were added !</info>');
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
private function addPostalCode($row, OutputInterface $output)
|
||||
|
@@ -18,13 +18,14 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Security\Core\Encoder\EncoderFactory;
|
||||
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder;
|
||||
|
||||
/**
|
||||
* Class SetPasswordCommand.
|
||||
*/
|
||||
class SetPasswordCommand extends Command
|
||||
{
|
||||
protected static $defaultDescription = 'set a password to user';
|
||||
|
||||
/**
|
||||
* SetPasswordCommand constructor.
|
||||
*/
|
||||
@@ -42,7 +43,7 @@ class SetPasswordCommand extends Command
|
||||
|
||||
public function _setPassword(User $user, $password)
|
||||
{
|
||||
$defaultEncoder = new MessageDigestPasswordEncoder('sha512', true, 5000);
|
||||
$defaultEncoder = new \Symfony\Component\PasswordHasher\Hasher\MessageDigestPasswordHasher('sha512', true, 5000);
|
||||
$encoders = [
|
||||
User::class => $defaultEncoder,
|
||||
];
|
||||
@@ -56,7 +57,6 @@ class SetPasswordCommand extends Command
|
||||
public function configure()
|
||||
{
|
||||
$this->setName('chill:user:set_password')
|
||||
->setDescription('set a password to user')
|
||||
->addArgument('username', InputArgument::REQUIRED, 'the user\'s '
|
||||
.'username you want to change password')
|
||||
->addArgument('password', InputArgument::OPTIONAL, 'the new password');
|
||||
@@ -80,6 +80,6 @@ class SetPasswordCommand extends Command
|
||||
|
||||
$this->_setPassword($user, $password);
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@@ -18,22 +18,20 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class SynchronizeEntityInfoViewsCommand extends Command
|
||||
{
|
||||
protected static $defaultDescription = 'Update or create sql views which provide info for various entities';
|
||||
|
||||
public function __construct(
|
||||
private readonly ViewEntityInfoManager $viewEntityInfoManager,
|
||||
) {
|
||||
parent::__construct('chill:db:sync-views');
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
$this
|
||||
->setDescription('Update or create sql views which provide info for various entities');
|
||||
}
|
||||
protected function configure(): void {}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$this->viewEntityInfoManager->synchronizeOnDB();
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user