mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch '52-repair-fixtures' into 'master'
Repair fixtures See merge request Chill-Projet/chill-bundles!494
This commit is contained in:
commit
813adc70f4
@ -61,7 +61,7 @@ class LoadCalendarRange extends Fixture implements FixtureGroupInterface, Ordere
|
||||
->setEmail('centreA@test.chill.social')
|
||||
->setLocationType($type = new LocationType())
|
||||
->setPhonenumber1(PhoneNumberUtil::getInstance()->parse('+3287653812'));
|
||||
$type->setTitle('Service');
|
||||
$type->setTitle(['fr' => 'Service']);
|
||||
$address->setStreet('Rue des Épaules')->setStreetNumber('14')
|
||||
->setPostcode($postCode = new PostalCode());
|
||||
$postCode->setCode('4145')->setName('Houte-Si-Plout')->setCountry(
|
||||
|
@ -12,6 +12,8 @@ declare(strict_types=1);
|
||||
namespace Chill\CalendarBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\CalendarBundle\Entity\Invite;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
@ -33,14 +35,21 @@ class LoadInvite extends Fixture implements FixtureGroupInterface
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$arr = [
|
||||
['name' => ['fr' => 'Rendez-vous décliné']],
|
||||
['name' => ['fr' => 'Rendez-vous accepté']],
|
||||
[
|
||||
'name' => ['fr' => 'Rendez-vous décliné'],
|
||||
'status' => Invite::DECLINED,
|
||||
],
|
||||
[
|
||||
'name' => ['fr' => 'Rendez-vous accepté'],
|
||||
'status' => Invite::ACCEPTED,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($arr as $a) {
|
||||
echo 'Creating calendar invite : ' . $a['name']['fr'] . "\n";
|
||||
$invite = (new Invite())
|
||||
->setStatus($a['name']);
|
||||
->setStatus($a['status'])
|
||||
->setUser($this->getRandomUser());
|
||||
$manager->persist($invite);
|
||||
$reference = 'Invite_' . $a['name']['fr'];
|
||||
$this->addReference($reference, $invite);
|
||||
@ -49,4 +58,11 @@ class LoadInvite extends Fixture implements FixtureGroupInterface
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
private function getRandomUser(): User
|
||||
{
|
||||
$userRef = array_rand(LoadUsers::$refs);
|
||||
|
||||
return $this->getReference($userRef);
|
||||
}
|
||||
}
|
||||
|
@ -11,11 +11,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\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\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
||||
use Chill\PersonBundle\Household\MembersEditorFactory;
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
@ -192,14 +194,20 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
|
||||
|
||||
private function preparePersonIds()
|
||||
{
|
||||
$centers = LoadCenters::$centers;
|
||||
|
||||
// @TODO: Remove this and make this service stateless
|
||||
$this->personIds = $this->em
|
||||
->createQuery(
|
||||
'SELECT p.id FROM ' . Person::class . ' p ' .
|
||||
'JOIN p.center c ' .
|
||||
'WHERE c.name = :center '
|
||||
'WHERE EXISTS( ' .
|
||||
'SELECT 1 FROM ' . PersonCenterHistory::class . ' pch ' .
|
||||
'JOIN pch.center c ' .
|
||||
'WHERE pch.person = p.id ' .
|
||||
'AND c.name IN (:authorized_centers)' .
|
||||
')'
|
||||
)
|
||||
->setParameter('center', 'Center A')
|
||||
->setParameter('authorized_centers', $centers)
|
||||
->getScalarResult();
|
||||
|
||||
shuffle($this->personIds);
|
||||
|
Loading…
x
Reference in New Issue
Block a user