mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,4 +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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\DataFixtures\ORM;
|
||||
@@ -6,15 +14,17 @@ namespace Chill\PersonBundle\DataFixtures\ORM;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\DataFixtures\Helper\PersonRandomHelper;
|
||||
use Chill\PersonBundle\Entity\Relationships\Relationship;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Chill\PersonBundle\Entity\Relationships\Relationship;
|
||||
|
||||
class LoadRelationships extends Fixture implements DependentFixtureInterface
|
||||
{
|
||||
use PersonRandomHelper;
|
||||
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
@@ -26,26 +36,25 @@ class LoadRelationships extends Fixture implements DependentFixtureInterface
|
||||
{
|
||||
return [
|
||||
LoadPeople::class,
|
||||
LoadRelations::class
|
||||
LoadRelations::class,
|
||||
];
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
for ($i = 0; $i < 15; $i++) {
|
||||
for ($i = 0; 15 > $i; ++$i) {
|
||||
$user = $this->getRandomUser();
|
||||
$date = new \DateTimeImmutable();
|
||||
$date = new DateTimeImmutable();
|
||||
$relationship = (new Relationship())
|
||||
->setFromPerson($this->getRandomPerson($this->em))
|
||||
->setToPerson($this->getRandomPerson($this->em))
|
||||
->setRelation($this->getReference(LoadRelations::RELATION_KEY.
|
||||
->setRelation($this->getReference(LoadRelations::RELATION_KEY .
|
||||
\random_int(0, count(LoadRelations::RELATIONS) - 1)))
|
||||
->setReverse((bool) random_int(0, 1))
|
||||
->setCreatedBy($user)
|
||||
->setUpdatedBy($user)
|
||||
->setCreatedAt($date)
|
||||
->setUpdatedAt($date)
|
||||
;
|
||||
->setUpdatedAt($date);
|
||||
$manager->persist($relationship);
|
||||
}
|
||||
|
||||
@@ -55,6 +64,7 @@ class LoadRelationships extends Fixture implements DependentFixtureInterface
|
||||
private function getRandomUser(): User
|
||||
{
|
||||
$userRef = array_rand(LoadUsers::$refs);
|
||||
|
||||
return $this->getReference($userRef);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user