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,34 +1,60 @@
<?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\EventBundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Persistence\ObjectManager;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Chill\EventBundle\Entity\Participation;
use Chill\MainBundle\Entity\Center;
use Chill\EventBundle\Entity\Event;
use Chill\EventBundle\Entity\Participation;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
use Chill\MainBundle\Entity\Center;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager;
/**
* Load Events and Participation
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
* @author Champs Libres <info@champs-libres.coop>
* Load Events and Participation.
*/
class LoadParticipation extends AbstractFixture implements OrderedFixtureInterface
{
/**
*
* @var \Faker\Generator
*/
protected $faker;
public function __construct()
{
$this->faker = \Faker\Factory::create('fr_FR');
}
public function createEvents(Center $center, ObjectManager $manager)
{
$expectedNumber = 20;
$events = [];
for ($i = 0; $i < $expectedNumber; ++$i) {
$event = (new Event())
->setDate($this->faker->dateTimeBetween('-2 years', '+6 months'))
->setName($this->faker->words(rand(2, 4), true))
->setType($this->getReference(LoadEventTypes::$refs[array_rand(LoadEventTypes::$refs)]))
->setCenter($center)
->setCircle(
$this->getReference(
LoadScopes::$references[array_rand(LoadScopes::$references)]
)
);
$manager->persist($event);
$events[] = $event;
}
return $events;
}
public function getOrder()
{
return 30010;
@@ -37,62 +63,36 @@ class LoadParticipation extends AbstractFixture implements OrderedFixtureInterfa
public function load(ObjectManager $manager)
{
$centers = $manager->getRepository('ChillMainBundle:Center')
->findAll();
foreach($centers as $center) {
->findAll();
foreach ($centers as $center) {
$people = $manager->getRepository('ChillPersonBundle:Person')
->findBy(array('center' => $center));
->findBy(['center' => $center]);
$events = $this->createEvents($center, $manager);
/* @var $person \Chill\PersonBundle\Entity\Person */
foreach ($people as $person) {
$nb = rand(0,3);
for ($i=0; $i<$nb; $i++) {
$nb = rand(0, 3);
for ($i = 0; $i < $nb; ++$i) {
$event = $events[array_rand($events)];
$role = $event->getType()->getRoles()->get(
array_rand($event->getType()->getRoles()->toArray()));
array_rand($event->getType()->getRoles()->toArray())
);
$status = $event->getType()->getStatuses()->get(
array_rand($event->getType()->getStatuses()->toArray()));
array_rand($event->getType()->getStatuses()->toArray())
);
$participation = (new Participation())
->setPerson($person)
->setRole($role)
->setStatus($status)
->setEvent($event)
;
->setPerson($person)
->setRole($role)
->setStatus($status)
->setEvent($event);
$manager->persist($participation);
}
}
}
$manager->flush();
}
public function createEvents(Center $center, ObjectManager $manager)
{
$expectedNumber = 20;
$events = array();
for($i=0; $i<$expectedNumber; $i++) {
$event = (new Event())
->setDate($this->faker->dateTimeBetween('-2 years', '+6 months'))
->setName($this->faker->words(rand(2,4), true))
->setType($this->getReference(LoadEventTypes::$refs[array_rand(LoadEventTypes::$refs)]))
->setCenter($center)
->setCircle(
$this->getReference(
LoadScopes::$references[array_rand(LoadScopes::$references)]
)
)
;
$manager->persist($event);
$events[] = $event;
}
return $events;
}
}