mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix LoadHousehold fixture
This commit is contained in:
parent
5ee0ab5ab8
commit
744b62184a
@ -11,11 +11,13 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\PersonBundle\DataFixtures\ORM;
|
namespace Chill\PersonBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
|
use Chill\MainBundle\DataFixtures\ORM\LoadCenters;
|
||||||
use Chill\MainBundle\DataFixtures\ORM\LoadPostalCodes;
|
use Chill\MainBundle\DataFixtures\ORM\LoadPostalCodes;
|
||||||
use Chill\MainBundle\Entity\Address;
|
use Chill\MainBundle\Entity\Address;
|
||||||
use Chill\MainBundle\Entity\PostalCode;
|
use Chill\MainBundle\Entity\PostalCode;
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
||||||
use Chill\PersonBundle\Household\MembersEditorFactory;
|
use Chill\PersonBundle\Household\MembersEditorFactory;
|
||||||
use DateInterval;
|
use DateInterval;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
@ -192,14 +194,20 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
|
|||||||
|
|
||||||
private function preparePersonIds()
|
private function preparePersonIds()
|
||||||
{
|
{
|
||||||
|
$centers = LoadCenters::$centers;
|
||||||
|
|
||||||
// @TODO: Remove this and make this service stateless
|
// @TODO: Remove this and make this service stateless
|
||||||
$this->personIds = $this->em
|
$this->personIds = $this->em
|
||||||
->createQuery(
|
->createQuery(
|
||||||
'SELECT p.id FROM ' . Person::class . ' p ' .
|
'SELECT p.id FROM ' . Person::class . ' p ' .
|
||||||
'JOIN p.center c ' .
|
'WHERE EXISTS( ' .
|
||||||
'WHERE c.name = :center '
|
'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();
|
->getScalarResult();
|
||||||
|
|
||||||
shuffle($this->personIds);
|
shuffle($this->personIds);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user