mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 19:13:49 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -16,8 +16,6 @@ use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Load CustomField for Report into database.
|
||||
*/
|
||||
@@ -68,7 +66,7 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
|
||||
];
|
||||
|
||||
for ($i = 0; 25 >= $i; ++$i) {
|
||||
$cFType = $cFTypes[random_int(0, count($cFTypes) - 1)];
|
||||
$cFType = $cFTypes[random_int(0, \count($cFTypes) - 1)];
|
||||
|
||||
$customField = (new CustomField())
|
||||
->setSlug("cf_report_{$i}")
|
||||
@@ -76,7 +74,7 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
|
||||
->setOptions($cFType['options'])
|
||||
->setName(['fr' => "CustomField {$i}"])
|
||||
->setOrdering(random_int(0, 1000) / 1000)
|
||||
->setCustomFieldsGroup($this->getReference('cf_group_report_' . (random_int(0, 3))));
|
||||
->setCustomFieldsGroup($this->getReference('cf_group_report_'.random_int(0, 3)));
|
||||
|
||||
$manager->persist($customField);
|
||||
}
|
||||
@@ -88,7 +86,7 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
|
||||
|
||||
private function createExpectedFields(ObjectManager $manager)
|
||||
{
|
||||
//report logement
|
||||
// report logement
|
||||
$reportLogement = $this->getReference('cf_group_report_logement');
|
||||
|
||||
$houseTitle = (new CustomField())
|
||||
@@ -144,7 +142,7 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
|
||||
->setCustomFieldsGroup($reportLogement);
|
||||
$manager->persist($descriptionLogement);
|
||||
|
||||
//report problems
|
||||
// report problems
|
||||
$reportEducation = $this->getReference('cf_group_report_education');
|
||||
|
||||
$title = (new CustomField())
|
||||
|
@@ -44,9 +44,9 @@ class LoadCustomFieldsGroup extends AbstractFixture implements OrderedFixtureInt
|
||||
$this->addReference('cf_group_report_education', $report);
|
||||
|
||||
for ($i = 0; 3 >= $i; ++$i) {
|
||||
$report = $this->createReport($manager, ['fr' => 'ZZ Rapport aléatoire ' . $i]);
|
||||
$report = $this->createReport($manager, ['fr' => 'ZZ Rapport aléatoire '.$i]);
|
||||
|
||||
$this->addReference('cf_group_report_' . $i, $report);
|
||||
$this->addReference('cf_group_report_'.$i, $report);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
@@ -62,7 +62,7 @@ class LoadCustomFieldsGroup extends AbstractFixture implements OrderedFixtureInt
|
||||
array $name,
|
||||
array $options = []
|
||||
) {
|
||||
echo $name['fr'] . " \n";
|
||||
echo $name['fr']." \n";
|
||||
|
||||
$cFGroup = (new CustomFieldsGroup())
|
||||
->setName($name)
|
||||
|
@@ -18,8 +18,6 @@ use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* Add a role CHILL_REPORT_UPDATE & CHILL_REPORT_CREATE for all groups except administrative,
|
||||
* and a role CHILL_REPORT_SEE for administrative.
|
||||
@@ -40,10 +38,10 @@ class LoadReportACL extends AbstractFixture implements OrderedFixtureInterface
|
||||
foreach (LoadScopes::$references as $scopeRef) {
|
||||
$scope = $this->getReference($scopeRef);
|
||||
printf("processing scope %s \n", $scope->getName()['en']);
|
||||
//create permission group
|
||||
// create permission group
|
||||
switch ($permissionsGroup->getName()) {
|
||||
case 'social':
|
||||
if ($scope->getName()['en'] === 'administrative') {
|
||||
if ('administrative' === $scope->getName()['en']) {
|
||||
printf("denying power on administrative \n");
|
||||
|
||||
break 2; // we do not want any power on administrative
|
||||
@@ -53,7 +51,7 @@ class LoadReportACL extends AbstractFixture implements OrderedFixtureInterface
|
||||
|
||||
case 'administrative':
|
||||
case 'direction':
|
||||
if (in_array($scope->getName()['en'], ['administrative', 'social'], true)) {
|
||||
if (\in_array($scope->getName()['en'], ['administrative', 'social'], true)) {
|
||||
printf("denying power on %s\n", $scope->getName()['en']);
|
||||
|
||||
break 2; // we do not want any power on social or administrative
|
||||
@@ -64,7 +62,7 @@ class LoadReportACL extends AbstractFixture implements OrderedFixtureInterface
|
||||
|
||||
printf(
|
||||
'Adding CHILL_REPORT_UPDATE & CHILL_REPORT_CREATE to %s '
|
||||
. "permission group, scope '%s' \n",
|
||||
."permission group, scope '%s' \n",
|
||||
$permissionsGroup->getName(),
|
||||
$scope->getName()['en']
|
||||
);
|
||||
|
@@ -16,16 +16,11 @@ use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\ReportBundle\Entity\Report;
|
||||
use DateTime;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Faker\Factory as FakerFactory;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
|
||||
use function count;
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* Load reports into DB.
|
||||
@@ -49,7 +44,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
{
|
||||
$this->createExpected($manager);
|
||||
|
||||
//create random 2 times, to allow multiple report on some people
|
||||
// create random 2 times, to allow multiple report on some people
|
||||
$this->createRandom($manager, 90);
|
||||
$this->createRandom($manager, 30);
|
||||
|
||||
@@ -66,7 +61,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
$report = (new Report())
|
||||
->setPerson($charline)
|
||||
->setCFGroup($this->getReference('cf_group_report_logement'))
|
||||
->setDate(new DateTime('2015-01-05'))
|
||||
->setDate(new \DateTime('2015-01-05'))
|
||||
->setScope($this->getReference('scope_social'));
|
||||
$this->fillReport($report);
|
||||
|
||||
@@ -81,7 +76,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
$people = $this->getPeopleRandom($percentage);
|
||||
|
||||
foreach ($people as $person) {
|
||||
//create a report, set logement or education report
|
||||
// create a report, set logement or education report
|
||||
$report = (new Report())
|
||||
->setPerson($person)
|
||||
->setCFGroup(
|
||||
@@ -97,16 +92,16 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
|
||||
private function fillReport(Report $report)
|
||||
{
|
||||
//setUser
|
||||
// setUser
|
||||
$usernameRef = array_rand(LoadUsers::$refs);
|
||||
$report->setUser(
|
||||
$this->getReference($usernameRef)
|
||||
);
|
||||
|
||||
//set date if null
|
||||
if ($report->getDate() === null) {
|
||||
//set date. 30% of the dates are 2015-05-01
|
||||
$expectedDate = new DateTime('2015-01-05');
|
||||
// set date if null
|
||||
if (null === $report->getDate()) {
|
||||
// set date. 30% of the dates are 2015-05-01
|
||||
$expectedDate = new \DateTime('2015-01-05');
|
||||
|
||||
if (random_int(0, 100) < 30) {
|
||||
$report->setDate($expectedDate);
|
||||
@@ -116,7 +111,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
}
|
||||
}
|
||||
|
||||
//fill data
|
||||
// fill data
|
||||
$datas = [];
|
||||
|
||||
foreach ($report->getCFGroup()->getCustomFields() as $field) {
|
||||
@@ -148,7 +143,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
->getRepository(Person::class)
|
||||
->findAll();
|
||||
|
||||
//keep only a part ($percentage) of the people
|
||||
// keep only a part ($percentage) of the people
|
||||
$selectedPeople = [];
|
||||
|
||||
foreach ($people as $person) {
|
||||
@@ -171,16 +166,16 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
$multiple = $field->getOptions()['multiple'];
|
||||
$other = $field->getOptions()['other'];
|
||||
|
||||
//add other if allowed
|
||||
// add other if allowed
|
||||
if ($other) {
|
||||
$choices[] = ['slug' => '_other'];
|
||||
}
|
||||
|
||||
//initialize results
|
||||
// initialize results
|
||||
$picked = [];
|
||||
|
||||
if ($multiple) {
|
||||
$numberSelected = random_int(1, count($choices) - 1);
|
||||
$numberSelected = random_int(1, \count($choices) - 1);
|
||||
|
||||
for ($i = 0; $i < $numberSelected; ++$i) {
|
||||
$picked[] = $this->pickChoice($choices);
|
||||
@@ -189,7 +184,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
if ($other) {
|
||||
$result = ['_other' => null, '_choices' => $picked];
|
||||
|
||||
if (in_array('_other', $picked, true)) {
|
||||
if (\in_array('_other', $picked, true)) {
|
||||
$result['_other'] = $this->faker->realText(70);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user