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,21 +1,38 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\DataFixtures\ORM;
use Chill\MainBundle\DataFixtures\ORM\LoadCenters;
use Chill\MainBundle\DataFixtures\ORM\LoadPostalCodes;
use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\PostalCode;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use DateTimeImmutable;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Persistence\ObjectManager;
use Iterator;
use Nelmio\Alice\Loader\NativeLoader;
use Nelmio\Alice\ObjectSet;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Chill\MainBundle\Entity\Address;
use Doctrine\ORM\EntityManagerInterface;
use function array_map;
class LoadThirdParty extends Fixture Implements DependentFixtureInterface
class LoadThirdParty extends Fixture implements DependentFixtureInterface
{
public function getDependencies()
{
return [
LoadCenters::class,
LoadPostalCodes::class,
];
}
public function load(ObjectManager $manager)
{
$thirdParties = $this->getThirdParties()->getObjects();
@@ -25,10 +42,10 @@ class LoadThirdParty extends Fixture Implements DependentFixtureInterface
// this is an address
continue;
}
$thirdParty->setCreatedAt(new \DateTimeImmutable('today'));
$thirdParty->setCreatedAt(new DateTimeImmutable('today'));
foreach ($this->getCenters() as $center) {
$thirdParty->addCenter($center);
$thirdParty->addCenter($center);
}
$manager->persist($thirdParty);
@@ -37,13 +54,31 @@ class LoadThirdParty extends Fixture Implements DependentFixtureInterface
$manager->flush();
}
private function getCenters(): \Iterator
private function createAddress(): ObjectSet
{
$references = \array_map(function($a) { return $a['ref']; },
LoadCenters::$centers);
$loader = new NativeLoader();
return $loader->loadData([
Address::class => [
'address1' => [
'name' => '<fr_FR:company()>',
'telephone' => '<fr_FR:phonenumber()>',
'email' => '<email()>',
'comment' => '<fr_FR:realTextBetween(10, 500)>',
],
],
]);
}
private function getCenters(): Iterator
{
$references = array_map(
function ($a) { return $a['ref']; },
LoadCenters::$centers
);
$number = random_int(1, count($references));
if ($number === 1) {
if (1 === $number) {
yield $this->getReference($references[\array_rand($references)]);
} else {
foreach (array_rand($references, $number) as $index) {
@@ -52,40 +87,6 @@ class LoadThirdParty extends Fixture Implements DependentFixtureInterface
}
}
public function getDependencies()
{
return [
LoadCenters::class,
LoadPostalCodes::class
];
}
private function getThirdParties(): ObjectSet
{
$loader = new NativeLoader();
$objectSet = $loader->loadData([
Address::class => [
'address{1..75}' => [
'street' => '<fr_FR:streetName()>',
'streetNumber' => '<fr_FR:buildingNumber()>',
'validFrom' => '<dateTimeBetween(\'-1 year\', \'now\')>',
'postCode' => $this->getPostalCode()
],
],
ThirdParty::class => [
'thirdparty{1..75}' => [
'name' => '<fr_FR:company()>',
'telephone' => '<fr_FR:phonenumber()>',
'email' => '<email()>',
'comment' => '<fr_FR:realTextBetween(10, 500)>',
'address' => '@address<current()>'
]
]
]);
return $objectSet;
}
private function getPostalCode(): PostalCode
{
$ref = LoadPostalCodes::$refs[\array_rand(LoadPostalCodes::$refs)];
@@ -93,22 +94,28 @@ class LoadThirdParty extends Fixture Implements DependentFixtureInterface
return $this->getReference($ref);
}
private function createAddress(): ObjectSet
private function getThirdParties(): ObjectSet
{
$loader = new NativeLoader();
$objectSet = $loader->loadData([
return $loader->loadData([
Address::class => [
'address1' => [
'address{1..75}' => [
'street' => '<fr_FR:streetName()>',
'streetNumber' => '<fr_FR:buildingNumber()>',
'validFrom' => '<dateTimeBetween(\'-1 year\', \'now\')>',
'postCode' => $this->getPostalCode(),
],
],
ThirdParty::class => [
'thirdparty{1..75}' => [
'name' => '<fr_FR:company()>',
'telephone' => '<fr_FR:phonenumber()>',
'email' => '<email()>',
'comment' => '<fr_FR:realTextBetween(10, 500)>'
]
]
'comment' => '<fr_FR:realTextBetween(10, 500)>',
'address' => '@address<current()>',
],
],
]);
return $objectSet;
}
}

View File

@@ -1,5 +1,12 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\DataFixtures\ORM;
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;
@@ -8,9 +15,7 @@ use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
use Doctrine\Persistence\ObjectManager;
/**
* Class LoadThirdPartyCategory
* @package Chill\ThirdPartyBundle\DataFixtures\ORM
* @author Mathieu Jaumotte mathieu.jaumotte@champs-libres.coop
* Class LoadThirdPartyCategory.
*/
class LoadThirdPartyCategory extends Fixture implements FixtureGroupInterface
{
@@ -22,19 +27,19 @@ class LoadThirdPartyCategory extends Fixture implements FixtureGroupInterface
public function load(ObjectManager $manager)
{
$categories = [
['name' => ['fr' => "maison médicale" ]],
['name' => ['fr' => "hôpital" ]],
['name' => ['fr' => "médecin généraliste" ]],
['name' => ['fr' => "pharmacien" ]],
['name' => ['fr' => "assistance aux personnes âgées" ]],
['name' => ['fr' => "assistante maternelle" ]],
['name' => ['fr' => "assistant social" ]],
['name' => ['fr' => "éducateur spécialisé" ]],
['name' => ['fr' => "infirmier.ère" ]],
['name' => ['fr' => 'maison médicale']],
['name' => ['fr' => 'hôpital']],
['name' => ['fr' => 'médecin généraliste']],
['name' => ['fr' => 'pharmacien']],
['name' => ['fr' => 'assistance aux personnes âgées']],
['name' => ['fr' => 'assistante maternelle']],
['name' => ['fr' => 'assistant social']],
['name' => ['fr' => 'éducateur spécialisé']],
['name' => ['fr' => 'infirmier.ère']],
];
foreach ( $categories as $val) {
print "Creating thirdparty category : " . $val['name']['fr'] . "\n";
foreach ($categories as $val) {
echo 'Creating thirdparty category : ' . $val['name']['fr'] . "\n";
$category = (new ThirdPartyCategory())
->setName($val['name'])
->setActive(true);

View File

@@ -1,5 +1,12 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\DataFixtures\ORM;
use Chill\ThirdPartyBundle\Entity\ThirdPartyProfession;
@@ -8,9 +15,7 @@ use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
use Doctrine\Persistence\ObjectManager;
/**
* Class LoadThirdPartyProfession
* @package Chill\ThirdPartyBundle\DataFixtures\ORM
* @author Mathieu Jaumotte mathieu.jaumotte@champs-libres.coop
* Class LoadThirdPartyProfession.
*/
class LoadThirdPartyProfession extends Fixture implements FixtureGroupInterface
{
@@ -22,17 +27,17 @@ class LoadThirdPartyProfession extends Fixture implements FixtureGroupInterface
public function load(ObjectManager $manager)
{
$professions = [
['name' => ['fr' => "Directeur" ]],
['name' => ['fr' => "Docteur" ]],
['name' => ['fr' => "Médecin" ]],
['name' => ['fr' => "Opérateur" ]],
['name' => ['fr' => "Personnel administratif" ]],
['name' => ['fr' => "Président" ]],
['name' => ['fr' => "Responsable infirmier.ère" ]],
['name' => ['fr' => 'Directeur']],
['name' => ['fr' => 'Docteur']],
['name' => ['fr' => 'Médecin']],
['name' => ['fr' => 'Opérateur']],
['name' => ['fr' => 'Personnel administratif']],
['name' => ['fr' => 'Président']],
['name' => ['fr' => 'Responsable infirmier.ère']],
];
foreach ( $professions as $val) {
print "Creating thirdparty professions : " . $val['name']['fr'] . "\n";
foreach ($professions as $val) {
echo 'Creating thirdparty professions : ' . $val['name']['fr'] . "\n";
$profession = (new ThirdPartyProfession())
->setName($val['name'])
->setActive(true);