cs: Fix code style (safe rules only).

This commit is contained in:
Pol Dellaiera
2021-11-23 14:06:38 +01:00
parent 149d7ce991
commit 8f96a1121d
1223 changed files with 65199 additions and 64625 deletions

View File

@@ -1,69 +1,57 @@
<?php
/*
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
/**
* Chill is a software for social workers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Command;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Intl\Intl;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Intl\Intl;
/*
* Load or update the languages entities command
*/
class LoadAndUpdateLanguagesCommand extends Command
{
public const INCLUDE_ANCIENT = 'include_ancient';
public const INCLUDE_REGIONAL_VERSION = 'include_regional';
// Array of ancien languages (to exclude)
private $ancientToExclude = ['ang', 'egy', 'fro', 'goh', 'grc', 'la', 'non', 'peo', 'pro', 'sga',
'dum', 'enm', 'frm', 'gmh', 'mga', 'akk', 'phn', 'zxx', 'got', 'und', ];
private $availableLanguages;
/**
* @var EntityManager
*/
private $entityManager;
private $availableLanguages;
// The regional version of language are language with _ in the code
// This array contains regional code to not exclude
private $regionalVersionToInclude = ["ro_MD"];
private $regionalVersionToInclude = ['ro_MD'];
// Array of ancien languages (to exclude)
private $ancientToExclude = ["ang", "egy", "fro", "goh", "grc", "la", "non", "peo", "pro", "sga",
"dum", "enm", "frm", "gmh", "mga", "akk", "phn", "zxx", "got", "und"];
const INCLUDE_REGIONAL_VERSION = 'include_regional';
const INCLUDE_ANCIENT = 'include_ancient';
/**
* LoadCountriesCommand constructor.
*
* @param EntityManager $entityManager
* @param $availableLanguages
*/
public function __construct(EntityManager $entityManager, $availableLanguages)
{
$this->entityManager=$entityManager;
$this->availableLanguages=$availableLanguages;
$this->entityManager = $entityManager;
$this->availableLanguages = $availableLanguages;
parent::__construct();
}
/*
* (non-PHPdoc)
* @see \Symfony\Component\Console\Command\Command::configure()
@@ -72,23 +60,24 @@ class LoadAndUpdateLanguagesCommand extends Command
{
$this
->setName('chill:main:languages:populate')
->setDescription('Load or update languages in db. This command does not delete existing '.
->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,
InputOption::VALUE_NONE,
'Include the regional languages. The regional languages are languages with code containing _ excepted '
. implode(',', $this->regionalVersionToInclude) . '.')
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) . '.')
;
self::INCLUDE_ANCIENT,
null,
InputOption::VALUE_NONE,
'Include the ancient languages that are languages with code '
. implode(', ', $this->ancientToExclude) . '.'
);
}
/*
* (non-PHPdoc)
* @see \Symfony\Component\Console\Command\Command::execute()
@@ -98,7 +87,7 @@ class LoadAndUpdateLanguagesCommand extends Command
$em = $this->entityManager;
$chillAvailableLanguages = $this->availableLanguages;
$languageBundle = Intl::getLanguageBundle();
$languages = array();
$languages = [];
foreach ($chillAvailableLanguages as $avLang) {
$languages[$avLang] = $languageBundle->getLanguageNames($avLang);
@@ -109,25 +98,25 @@ class LoadAndUpdateLanguagesCommand extends Command
foreach ($languageCodes as $code) {
$excludeCode = (
(
! $input->getOption(self::INCLUDE_REGIONAL_VERSION)
!$input->getOption(self::INCLUDE_REGIONAL_VERSION)
and strpos($code, '_')
and !in_array($code, $this->regionalVersionToInclude)
) or (
! $input->getOption(self::INCLUDE_ANCIENT)
!$input->getOption(self::INCLUDE_ANCIENT)
and in_array($code, $this->ancientToExclude)
)
);
$langageDB = $em->getRepository('ChillMainBundle:Language')->find($code);
if(! $excludeCode) {
if (! $langageDB) {
if (!$excludeCode) {
if (!$langageDB) {
$langageDB = new \Chill\MainBundle\Entity\Language();
$langageDB->setId($code);
$em->persist($langageDB);
}
$avLangNames = array();
$avLangNames = [];
foreach ($chillAvailableLanguages as $avLang) {
$avLangNames[$avLang] = $languages[$avLang][$code];
@@ -135,10 +124,10 @@ class LoadAndUpdateLanguagesCommand extends Command
$langageDB->setName($avLangNames);
} else {
if($langageDB) {
if ($langageDB) {
$em->remove($langageDB);
}
echo "Code excluded : ".$code." - ".$languageBundle->getLanguageName($code)."\n";
echo 'Code excluded : ' . $code . ' - ' . $languageBundle->getLanguageName($code) . "\n";
}
}