mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 11:03:50 +00:00
Pass class as second parameter to getReference() fixture method
This commit is contained in:
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
@@ -64,9 +65,9 @@ class LoadAccompanyingPeriodWork extends \Doctrine\Bundle\FixturesBundle\Fixture
|
||||
->setStartDate(new \DateTimeImmutable('today'))
|
||||
->addPerson($period->getPersons()->first())
|
||||
->setCreatedAt(new \DateTimeImmutable())
|
||||
->setCreatedBy($this->getReference('center a_social', null))
|
||||
->setCreatedBy($this->getReference('center a_social', User::class))
|
||||
->setUpdatedAt(new \DateTimeImmutable())
|
||||
->setUpdatedBy($this->getReference('center a_social', null));
|
||||
->setUpdatedBy($this->getReference('center a_social', User::class));
|
||||
$manager->persist($work);
|
||||
|
||||
if ($action->getEvaluations()->count() > 0) {
|
||||
@@ -91,9 +92,9 @@ class LoadAccompanyingPeriodWork extends \Doctrine\Bundle\FixturesBundle\Fixture
|
||||
->setStartDate(new \DateTimeImmutable('today'))
|
||||
->addPerson($period->getPersons()->first())
|
||||
->setCreatedAt(new \DateTimeImmutable())
|
||||
->setCreatedBy($this->getReference('center a_social', null))
|
||||
->setCreatedBy($this->getReference('center a_social', User::class))
|
||||
->setUpdatedAt(new \DateTimeImmutable())
|
||||
->setUpdatedBy($this->getReference('center a_social', null));
|
||||
->setUpdatedBy($this->getReference('center a_social', User::class));
|
||||
$manager->persist($work);
|
||||
$ev = new AccompanyingPeriod\AccompanyingPeriodWorkEvaluation();
|
||||
$ev->setAccompanyingPeriodWork($work)
|
||||
|
@@ -16,6 +16,7 @@ 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\Household\Position;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
||||
use Chill\PersonBundle\Household\MembersEditorFactory;
|
||||
@@ -127,7 +128,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
|
||||
|
||||
foreach ($this->getRandomPersons(1, 3) as $person) {
|
||||
$date = $startDate->add(new \DateInterval('P'.\random_int(1, 200).'W'));
|
||||
$position = $this->getReference(LoadHouseholdPosition::ADULT, null);
|
||||
$position = $this->getReference(LoadHouseholdPosition::ADULT, Position::class);
|
||||
|
||||
$movement->addMovement($date, $person, $position, 0 === $k, 'self generated');
|
||||
++$k;
|
||||
@@ -136,7 +137,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
|
||||
// load children
|
||||
foreach ($this->getRandomPersons(0, 3) as $person) {
|
||||
$date = $startDate->add(new \DateInterval('P'.\random_int(1, 200).'W'));
|
||||
$position = $this->getReference(LoadHouseholdPosition::CHILD, null);
|
||||
$position = $this->getReference(LoadHouseholdPosition::CHILD, Position::class);
|
||||
|
||||
$movement->addMovement($date, $person, $position, 0 === $k, 'self generated');
|
||||
++$k;
|
||||
@@ -145,7 +146,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
|
||||
// load children out
|
||||
foreach ($this->getRandomPersons(0, 2) as $person) {
|
||||
$date = $startDate->add(new \DateInterval('P'.\random_int(1, 200).'W'));
|
||||
$position = $this->getReference(LoadHouseholdPosition::CHILD_OUT, null);
|
||||
$position = $this->getReference(LoadHouseholdPosition::CHILD_OUT, Position::class);
|
||||
|
||||
$movement->addMovement($date, $person, $position, 0 === $k, 'self generated');
|
||||
++$k;
|
||||
@@ -161,7 +162,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
|
||||
{
|
||||
$ref = LoadPostalCodes::$refs[\array_rand(LoadPostalCodes::$refs)];
|
||||
|
||||
return $this->getReference($ref, null);
|
||||
return $this->getReference($ref, PostalCode::class);
|
||||
}
|
||||
|
||||
private function getRandomPersons(int $min, int $max): array
|
||||
|
@@ -358,8 +358,8 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
|
||||
|
||||
if (\random_int(0, 10) > 3) {
|
||||
// always add social scope:
|
||||
$accompanyingPeriod->addScope($this->getReference('scope_social', null));
|
||||
$origin = $this->getReference(LoadAccompanyingPeriodOrigin::ACCOMPANYING_PERIOD_ORIGIN, null);
|
||||
$accompanyingPeriod->addScope($this->getReference('scope_social', Scope::class));
|
||||
$origin = $this->getReference(LoadAccompanyingPeriodOrigin::ACCOMPANYING_PERIOD_ORIGIN, AccompanyingPeriod\Origin::class);
|
||||
$accompanyingPeriod->setOrigin($origin);
|
||||
$accompanyingPeriod->setIntensity('regular');
|
||||
$accompanyingPeriod->setAddressLocation($this->createAddress());
|
||||
@@ -472,7 +472,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
|
||||
{
|
||||
$ref = LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)];
|
||||
|
||||
return $this->getReference($ref, null);
|
||||
return $this->getReference($ref, PostalCode::class);
|
||||
}
|
||||
|
||||
private function getRandomSocialIssue(): SocialIssue
|
||||
|
@@ -12,7 +12,9 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
|
||||
use Chill\MainBundle\Entity\PermissionsGroup;
|
||||
use Chill\MainBundle\Entity\RoleScope;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
@@ -33,8 +35,8 @@ class LoadPersonACL extends AbstractFixture implements OrderedFixtureInterface
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
|
||||
$permissionsGroup = $this->getReference($permissionsGroupRef, null);
|
||||
$scopeSocial = $this->getReference('scope_social', null);
|
||||
$permissionsGroup = $this->getReference($permissionsGroupRef, PermissionsGroup::class);
|
||||
$scopeSocial = $this->getReference('scope_social', Scope::class);
|
||||
|
||||
// create permission group
|
||||
switch ($permissionsGroup->getName()) {
|
||||
|
@@ -14,6 +14,7 @@ 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\Relation;
|
||||
use Chill\PersonBundle\Entity\Relationships\Relationship;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
@@ -46,7 +47,7 @@ class LoadRelationships extends Fixture implements DependentFixtureInterface
|
||||
->setFromPerson($this->getRandomPerson($this->em))
|
||||
->setToPerson($this->getRandomPerson($this->em))
|
||||
->setRelation($this->getReference(LoadRelations::RELATION_KEY.
|
||||
random_int(0, \count(LoadRelations::RELATIONS) - 1), null))
|
||||
random_int(0, \count(LoadRelations::RELATIONS) - 1), Relation::class))
|
||||
->setReverse((bool) random_int(0, 1))
|
||||
->setCreatedBy($user)
|
||||
->setUpdatedBy($user)
|
||||
@@ -74,6 +75,6 @@ class LoadRelationships extends Fixture implements DependentFixtureInterface
|
||||
{
|
||||
$userRef = array_rand(LoadUsers::$refs);
|
||||
|
||||
return $this->getReference($userRef, null);
|
||||
return $this->getReference($userRef, User::class);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user