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:
@@ -14,9 +14,7 @@ namespace Chill\MainBundle\Command;
|
||||
use Chill\MainBundle\Entity\Language;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Intl\Languages;
|
||||
|
||||
@@ -24,7 +22,7 @@ use Symfony\Component\Intl\Languages;
|
||||
* Load or update the languages entities command
|
||||
*/
|
||||
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:languages:populate')]
|
||||
class LoadAndUpdateLanguagesCommand extends Command
|
||||
class LoadAndUpdateLanguagesCommand
|
||||
{
|
||||
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)
|
||||
{
|
||||
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()
|
||||
*/
|
||||
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;
|
||||
$chillAvailableLanguages = $this->parameterBag->get('chill_main.available_languages');
|
||||
@@ -88,11 +65,11 @@ class LoadAndUpdateLanguagesCommand extends Command
|
||||
foreach (Languages::getNames() as $code => $lang) {
|
||||
$excludeCode = (
|
||||
(
|
||||
null === $input->getOption(self::INCLUDE_REGIONAL_VERSION)
|
||||
null === $include_regional
|
||||
&& strpos($code, '_')
|
||||
&& !\in_array($code, $this->regionalVersionToInclude, true)
|
||||
) || (
|
||||
null === $input->getOption(self::INCLUDE_ANCIENT)
|
||||
null === $include_ancient
|
||||
&& \in_array($code, $this->ancientToExclude, true)
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user