Pass class as second parameter to getReference() fixture method

This commit is contained in:
Julie Lenaerts 2024-11-28 13:28:52 +01:00
parent 19e6ceba28
commit f820273dd7
27 changed files with 94 additions and 59 deletions

View File

@ -12,8 +12,12 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\DataFixtures\ORM; namespace Chill\ActivityBundle\DataFixtures\ORM;
use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Entity\ActivityReason;
use Chill\ActivityBundle\Entity\ActivityType;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes; use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
use Chill\MainBundle\DataFixtures\ORM\LoadUsers; use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
@ -89,7 +93,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
{ {
$reasonRef = LoadActivityReason::$references[array_rand(LoadActivityReason::$references)]; $reasonRef = LoadActivityReason::$references[array_rand(LoadActivityReason::$references)];
return $this->getReference($reasonRef, null); return $this->getReference($reasonRef, ActivityReason::class);
} }
/** /**
@ -99,7 +103,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
{ {
$typeRef = LoadActivityType::$references[array_rand(LoadActivityType::$references)]; $typeRef = LoadActivityType::$references[array_rand(LoadActivityType::$references)];
return $this->getReference($typeRef, null); return $this->getReference($typeRef, ActivityType::class);
} }
/** /**
@ -109,7 +113,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
{ {
$scopeRef = LoadScopes::$references[array_rand(LoadScopes::$references)]; $scopeRef = LoadScopes::$references[array_rand(LoadScopes::$references)];
return $this->getReference($scopeRef, null); return $this->getReference($scopeRef, Scope::class);
} }
/** /**
@ -119,6 +123,6 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
{ {
$userRef = array_rand(LoadUsers::$refs); $userRef = array_rand(LoadUsers::$refs);
return $this->getReference($userRef, null); return $this->getReference($userRef, User::class);
} }
} }

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\DataFixtures\ORM; namespace Chill\ActivityBundle\DataFixtures\ORM;
use Chill\ActivityBundle\Entity\ActivityReason; use Chill\ActivityBundle\Entity\ActivityReason;
use Chill\ActivityBundle\Entity\ActivityReasonCategory;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -56,7 +57,7 @@ class LoadActivityReason extends AbstractFixture implements OrderedFixtureInterf
$activityReason = (new ActivityReason()) $activityReason = (new ActivityReason())
->setName($r['name']) ->setName($r['name'])
->setActive(true) ->setActive(true)
->setCategory($this->getReference($r['category'], null)); ->setCategory($this->getReference($r['category'], ActivityReasonCategory::class));
$manager->persist($activityReason); $manager->persist($activityReason);
$reference = 'activity_reason_'.$r['name']['en']; $reference = 'activity_reason_'.$r['name']['en'];
$this->addReference($reference, $activityReason); $this->addReference($reference, $activityReason);

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\DataFixtures\ORM; namespace Chill\ActivityBundle\DataFixtures\ORM;
use Chill\ActivityBundle\Entity\ActivityType; use Chill\ActivityBundle\Entity\ActivityType;
use Chill\ActivityBundle\Entity\ActivityTypeCategory;
use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -57,7 +58,7 @@ class LoadActivityType extends Fixture implements OrderedFixtureInterface
echo 'Creating activity type : '.$t['name']['fr'].' (cat:'.$t['category']." \n"; echo 'Creating activity type : '.$t['name']['fr'].' (cat:'.$t['category']." \n";
$activityType = (new ActivityType()) $activityType = (new ActivityType())
->setName($t['name']) ->setName($t['name'])
->setCategory($this->getReference('activity_type_cat_'.$t['category'], null)) ->setCategory($this->getReference('activity_type_cat_'.$t['category'], ActivityTypeCategory::class))
->setSocialIssuesVisible(1) ->setSocialIssuesVisible(1)
->setSocialActionsVisible(1); ->setSocialActionsVisible(1);
$manager->persist($activityType); $manager->persist($activityType);

View File

@ -15,7 +15,9 @@ use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Chill\ActivityBundle\Security\Authorization\ActivityVoter; use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup; use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes; use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
use Chill\MainBundle\Entity\PermissionsGroup;
use Chill\MainBundle\Entity\RoleScope; use Chill\MainBundle\Entity\RoleScope;
use Chill\MainBundle\Entity\Scope;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -34,10 +36,10 @@ class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterfac
public function load(ObjectManager $manager): void public function load(ObjectManager $manager): void
{ {
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) { foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
$permissionsGroup = $this->getReference($permissionsGroupRef, null); $permissionsGroup = $this->getReference($permissionsGroupRef, PermissionsGroup::class);
foreach (LoadScopes::$references as $scopeRef) { foreach (LoadScopes::$references as $scopeRef) {
$scope = $this->getReference($scopeRef, null); $scope = $this->getReference($scopeRef, Scope::class);
// create permission group // create permission group
switch ($permissionsGroup->getName()) { switch ($permissionsGroup->getName()) {
case 'social': case 'social':

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\AsideActivityBundle\DataFixtures\ORM; namespace Chill\AsideActivityBundle\DataFixtures\ORM;
use Chill\AsideActivityBundle\Entity\AsideActivity; use Chill\AsideActivityBundle\Entity\AsideActivity;
use Chill\AsideActivityBundle\Entity\AsideActivityCategory;
use Chill\MainBundle\DataFixtures\ORM\LoadUsers; use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
use Chill\MainBundle\Repository\UserRepository; use Chill\MainBundle\Repository\UserRepository;
use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Bundle\FixturesBundle\Fixture;
@ -43,7 +44,7 @@ class LoadAsideActivity extends Fixture implements DependentFixtureInterface
->setUpdatedAt(new \DateTimeImmutable('now')) ->setUpdatedAt(new \DateTimeImmutable('now'))
->setUpdatedBy($user) ->setUpdatedBy($user)
->setType( ->setType(
$this->getReference('aside_activity_category_0', null) $this->getReference('aside_activity_category_0', AsideActivityCategory::class)
) )
->setDate((new \DateTimeImmutable('today')) ->setDate((new \DateTimeImmutable('today'))
->sub(new \DateInterval('P'.\random_int(1, 100).'D'))); ->sub(new \DateInterval('P'.\random_int(1, 100).'D')));

View File

@ -37,7 +37,7 @@ class LoadCalendarACL extends Fixture implements OrderedFixtureInterface
foreach (LoadPermissionsGroup::$refs as $permissionGroupRef) { foreach (LoadPermissionsGroup::$refs as $permissionGroupRef) {
/** @var PermissionsGroup $group */ /** @var PermissionsGroup $group */
$group = $this->getReference($permissionGroupRef, null); $group = $this->getReference($permissionGroupRef, PermissionsGroup::class);
foreach ($roleScopes as $scope) { foreach ($roleScopes as $scope) {
$group->addRoleScope($scope); $group->addRoleScope($scope);

View File

@ -63,6 +63,6 @@ class LoadInvite extends Fixture implements FixtureGroupInterface
{ {
$userRef = array_rand(LoadUsers::$refs); $userRef = array_rand(LoadUsers::$refs);
return $this->getReference($userRef, null); return $this->getReference($userRef, User::class);
} }
} }

View File

@ -14,7 +14,9 @@ namespace Chill\DocStoreBundle\DataFixtures\ORM;
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter; use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup; use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes; use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
use Chill\MainBundle\Entity\PermissionsGroup;
use Chill\MainBundle\Entity\RoleScope; use Chill\MainBundle\Entity\RoleScope;
use Chill\MainBundle\Entity\Scope;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -32,11 +34,11 @@ class LoadDocumentACL extends AbstractFixture implements OrderedFixtureInterface
public function load(ObjectManager $manager): void public function load(ObjectManager $manager): void
{ {
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) { foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
$permissionsGroup = $this->getReference($permissionsGroupRef, null); $permissionsGroup = $this->getReference($permissionsGroupRef, PermissionsGroup::class);
printf("processing permission group %s \n", $permissionsGroup->getName()); printf("processing permission group %s \n", $permissionsGroup->getName());
foreach (LoadScopes::$references as $scopeRef) { foreach (LoadScopes::$references as $scopeRef) {
$scope = $this->getReference($scopeRef, null); $scope = $this->getReference($scopeRef, Scope::class);
printf("processing scope %s \n", $scope->getName()['en']); printf("processing scope %s \n", $scope->getName()['en']);
// create permission group // create permission group
switch ($permissionsGroup->getName()) { switch ($permissionsGroup->getName()) {

View File

@ -12,9 +12,11 @@ declare(strict_types=1);
namespace Chill\EventBundle\DataFixtures\ORM; namespace Chill\EventBundle\DataFixtures\ORM;
use Chill\EventBundle\Entity\Event; use Chill\EventBundle\Entity\Event;
use Chill\EventBundle\Entity\EventType;
use Chill\EventBundle\Entity\Participation; use Chill\EventBundle\Entity\Participation;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes; use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\Scope;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
@ -44,12 +46,12 @@ class LoadParticipation extends AbstractFixture implements OrderedFixtureInterfa
$event = (new Event()) $event = (new Event())
->setDate($this->faker->dateTimeBetween('-2 years', '+6 months')) ->setDate($this->faker->dateTimeBetween('-2 years', '+6 months'))
->setName($this->faker->words(random_int(2, 4), true)) ->setName($this->faker->words(random_int(2, 4), true))
->setType($this->getReference(LoadEventTypes::$refs[array_rand(LoadEventTypes::$refs)], null)) ->setType($this->getReference(LoadEventTypes::$refs[array_rand(LoadEventTypes::$refs)], EventType::class))
->setCenter($center) ->setCenter($center)
->setCircle( ->setCircle(
$this->getReference( $this->getReference(
LoadScopes::$references[array_rand(LoadScopes::$references)], LoadScopes::$references[array_rand(LoadScopes::$references)],
null Scope::class
) )
); );
$manager->persist($event); $manager->persist($event);

View File

@ -13,7 +13,9 @@ namespace Chill\EventBundle\DataFixtures\ORM;
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup; use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes; use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
use Chill\MainBundle\Entity\PermissionsGroup;
use Chill\MainBundle\Entity\RoleScope; use Chill\MainBundle\Entity\RoleScope;
use Chill\MainBundle\Entity\Scope;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -31,10 +33,10 @@ class LoadRolesACL extends AbstractFixture implements OrderedFixtureInterface
public function load(ObjectManager $manager): void public function load(ObjectManager $manager): void
{ {
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) { foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
$permissionsGroup = $this->getReference($permissionsGroupRef, null); $permissionsGroup = $this->getReference($permissionsGroupRef, PermissionsGroup::class);
foreach (LoadScopes::$references as $scopeRef) { foreach (LoadScopes::$references as $scopeRef) {
$scope = $this->getReference($scopeRef, null); $scope = $this->getReference($scopeRef, Scope::class);
// create permission group // create permission group
switch ($permissionsGroup->getName()) { switch ($permissionsGroup->getName()) {
case 'social': case 'social':

View File

@ -24,20 +24,20 @@ trait LoadAbstractNotificationsTrait
return; return;
foreach ($this->notifs as $notif) { foreach ($this->notifs as $notif) {
$entityId = $this->getReference($notif['entityRef'], null)->getId(); $entityId = $this->getReference($notif['entityRef'], Notification::class)->getId();
echo 'Adding notification for '.$notif['entityClass'].'(entity id:'.$entityId.")\n"; echo 'Adding notification for '.$notif['entityClass'].'(entity id:'.$entityId.")\n";
$newNotif = (new Notification()) $newNotif = (new Notification())
->setMessage($notif['message']) ->setMessage($notif['message'])
->setSender($this->getReference($notif['sender'], null)) ->setSender($this->getReference($notif['sender'], Notification::class))
->setRelatedEntityClass($notif['entityClass']) ->setRelatedEntityClass($notif['entityClass'])
->setRelatedEntityId($entityId) ->setRelatedEntityId($entityId)
->setDate(new \DateTimeImmutable('now')) ->setDate(new \DateTimeImmutable('now'))
->setRead([]); ->setRead([]);
foreach ($notif['addressees'] as $addressee) { foreach ($notif['addressees'] as $addressee) {
$newNotif->addAddressee($this->getReference($addressee, null)); $newNotif->addAddressee($this->getReference($addressee, Notification::class));
} }
$manager->persist($newNotif); $manager->persist($newNotif);

View File

@ -13,6 +13,7 @@ namespace Chill\MainBundle\DataFixtures\ORM;
use Chill\MainBundle\Doctrine\Model\Point; use Chill\MainBundle\Doctrine\Model\Point;
use Chill\MainBundle\Entity\AddressReference; use Chill\MainBundle\Entity\AddressReference;
use Chill\MainBundle\Entity\PostalCode;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -70,7 +71,7 @@ class LoadAddressReferences extends AbstractFixture implements ContainerAwareInt
$ar->setPoint($this->getRandomPoint()); $ar->setPoint($this->getRandomPoint());
$ar->setPostcode($this->getReference( $ar->setPostcode($this->getReference(
LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)], LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)],
null PostalCode::class
)); ));
$ar->setMunicipalityCode($ar->getPostcode()->getCode()); $ar->setMunicipalityCode($ar->getPostcode()->getCode());

View File

@ -11,7 +11,9 @@ declare(strict_types=1);
namespace Chill\MainBundle\DataFixtures\ORM; namespace Chill\MainBundle\DataFixtures\ORM;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\GroupCenter; use Chill\MainBundle\Entity\GroupCenter;
use Chill\MainBundle\Entity\PermissionsGroup;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -30,8 +32,8 @@ class LoadGroupCenters extends AbstractFixture implements OrderedFixtureInterfac
foreach (LoadCenters::$refs as $centerRef) { foreach (LoadCenters::$refs as $centerRef) {
foreach (LoadPermissionsGroup::$refs as $permissionGroupRef) { foreach (LoadPermissionsGroup::$refs as $permissionGroupRef) {
$GroupCenter = new GroupCenter(); $GroupCenter = new GroupCenter();
$GroupCenter->setCenter($this->getReference($centerRef, null)); $GroupCenter->setCenter($this->getReference($centerRef, Center::class));
$GroupCenter->setPermissionsGroup($this->getReference($permissionGroupRef, null)); $GroupCenter->setPermissionsGroup($this->getReference($permissionGroupRef, PermissionsGroup::class));
$manager->persist($GroupCenter); $manager->persist($GroupCenter);

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\DataFixtures\ORM; namespace Chill\MainBundle\DataFixtures\ORM;
use Chill\MainBundle\Entity\PermissionsGroup; use Chill\MainBundle\Entity\PermissionsGroup;
use Chill\MainBundle\Entity\RoleScope;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -59,7 +60,7 @@ class LoadPermissionsGroup extends AbstractFixture implements OrderedFixtureInte
$permissionGroup->setName($new['name']); $permissionGroup->setName($new['name']);
foreach ($new['role_scopes'] as $roleScopeRef) { foreach ($new['role_scopes'] as $roleScopeRef) {
$permissionGroup->addRoleScope($this->getReference($roleScopeRef, null)); $permissionGroup->addRoleScope($this->getReference($roleScopeRef, RoleScope::class));
} }
$manager->persist($permissionGroup); $manager->persist($permissionGroup);

View File

@ -365,7 +365,7 @@ class LoadPostalCodes extends AbstractFixture implements OrderedFixtureInterface
$manager->persist($c); $manager->persist($c);
$ref = 'postal_code_'.$code[0]; $ref = 'postal_code_'.$code[0];
if (!$this->hasReference($ref, null)) { if (!$this->hasReference($ref, PostalCode::class)) {
$this->addReference($ref, $c); $this->addReference($ref, $c);
self::$refs[] = $ref; self::$refs[] = $ref;
} }

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\DataFixtures\ORM; namespace Chill\MainBundle\DataFixtures\ORM;
use Chill\MainBundle\Entity\RoleScope; use Chill\MainBundle\Entity\RoleScope;
use Chill\MainBundle\Entity\Scope;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -55,8 +56,8 @@ class LoadRoleScopes extends AbstractFixture implements OrderedFixtureInterface
foreach (LoadScopes::$references as $scopeReference) { foreach (LoadScopes::$references as $scopeReference) {
$roleScope = new RoleScope(); $roleScope = new RoleScope();
$roleScope->setRole($key) $roleScope->setRole($key)
->setScope($this->getReference($scopeReference, null)); ->setScope($this->getReference($scopeReference, Scope::class));
$reference = 'role_scope_'.$key.'_'.$this->getReference($scopeReference, null)->getName()['en']; $reference = 'role_scope_'.$key.'_'.$this->getReference($scopeReference, Scope::class)->getName()['en'];
echo "Creating {$reference} \n"; echo "Creating {$reference} \n";
$this->addReference($reference, $roleScope); $this->addReference($reference, $roleScope);
$manager->persist($roleScope); $manager->persist($roleScope);

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\DataFixtures\ORM; namespace Chill\MainBundle\DataFixtures\ORM;
use Chill\MainBundle\Entity\GroupCenter;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
@ -80,7 +81,7 @@ class LoadUsers extends AbstractFixture implements ContainerAwareInterface, Orde
->setEmail(sprintf('%s@chill.social', \str_replace(' ', '', (string) $username))); ->setEmail(sprintf('%s@chill.social', \str_replace(' ', '', (string) $username)));
foreach ($params['groupCenterRefs'] as $groupCenterRef) { foreach ($params['groupCenterRefs'] as $groupCenterRef) {
$user->addGroupCenter($this->getReference($groupCenterRef, null)); $user->addGroupCenter($this->getReference($groupCenterRef, GroupCenter::class));
} }
echo 'Creating user '.$username."... \n"; echo 'Creating user '.$username."... \n";

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\DataFixtures\ORM; namespace Chill\PersonBundle\DataFixtures\ORM;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\SocialWork\Evaluation; use Chill\PersonBundle\Entity\SocialWork\Evaluation;
use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Chill\PersonBundle\Entity\SocialWork\SocialAction;
@ -64,9 +65,9 @@ class LoadAccompanyingPeriodWork extends \Doctrine\Bundle\FixturesBundle\Fixture
->setStartDate(new \DateTimeImmutable('today')) ->setStartDate(new \DateTimeImmutable('today'))
->addPerson($period->getPersons()->first()) ->addPerson($period->getPersons()->first())
->setCreatedAt(new \DateTimeImmutable()) ->setCreatedAt(new \DateTimeImmutable())
->setCreatedBy($this->getReference('center a_social', null)) ->setCreatedBy($this->getReference('center a_social', User::class))
->setUpdatedAt(new \DateTimeImmutable()) ->setUpdatedAt(new \DateTimeImmutable())
->setUpdatedBy($this->getReference('center a_social', null)); ->setUpdatedBy($this->getReference('center a_social', User::class));
$manager->persist($work); $manager->persist($work);
if ($action->getEvaluations()->count() > 0) { if ($action->getEvaluations()->count() > 0) {
@ -91,9 +92,9 @@ class LoadAccompanyingPeriodWork extends \Doctrine\Bundle\FixturesBundle\Fixture
->setStartDate(new \DateTimeImmutable('today')) ->setStartDate(new \DateTimeImmutable('today'))
->addPerson($period->getPersons()->first()) ->addPerson($period->getPersons()->first())
->setCreatedAt(new \DateTimeImmutable()) ->setCreatedAt(new \DateTimeImmutable())
->setCreatedBy($this->getReference('center a_social', null)) ->setCreatedBy($this->getReference('center a_social', User::class))
->setUpdatedAt(new \DateTimeImmutable()) ->setUpdatedAt(new \DateTimeImmutable())
->setUpdatedBy($this->getReference('center a_social', null)); ->setUpdatedBy($this->getReference('center a_social', User::class));
$manager->persist($work); $manager->persist($work);
$ev = new AccompanyingPeriod\AccompanyingPeriodWorkEvaluation(); $ev = new AccompanyingPeriod\AccompanyingPeriodWorkEvaluation();
$ev->setAccompanyingPeriodWork($work) $ev->setAccompanyingPeriodWork($work)

View File

@ -16,6 +16,7 @@ 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\Household\Position;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory; use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
use Chill\PersonBundle\Household\MembersEditorFactory; use Chill\PersonBundle\Household\MembersEditorFactory;
@ -127,7 +128,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
foreach ($this->getRandomPersons(1, 3) as $person) { foreach ($this->getRandomPersons(1, 3) as $person) {
$date = $startDate->add(new \DateInterval('P'.\random_int(1, 200).'W')); $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'); $movement->addMovement($date, $person, $position, 0 === $k, 'self generated');
++$k; ++$k;
@ -136,7 +137,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
// load children // load children
foreach ($this->getRandomPersons(0, 3) as $person) { foreach ($this->getRandomPersons(0, 3) as $person) {
$date = $startDate->add(new \DateInterval('P'.\random_int(1, 200).'W')); $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'); $movement->addMovement($date, $person, $position, 0 === $k, 'self generated');
++$k; ++$k;
@ -145,7 +146,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
// load children out // load children out
foreach ($this->getRandomPersons(0, 2) as $person) { foreach ($this->getRandomPersons(0, 2) as $person) {
$date = $startDate->add(new \DateInterval('P'.\random_int(1, 200).'W')); $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'); $movement->addMovement($date, $person, $position, 0 === $k, 'self generated');
++$k; ++$k;
@ -161,7 +162,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
{ {
$ref = LoadPostalCodes::$refs[\array_rand(LoadPostalCodes::$refs)]; $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 private function getRandomPersons(int $min, int $max): array

View File

@ -358,8 +358,8 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
if (\random_int(0, 10) > 3) { if (\random_int(0, 10) > 3) {
// always add social scope: // always add social scope:
$accompanyingPeriod->addScope($this->getReference('scope_social', null)); $accompanyingPeriod->addScope($this->getReference('scope_social', Scope::class));
$origin = $this->getReference(LoadAccompanyingPeriodOrigin::ACCOMPANYING_PERIOD_ORIGIN, null); $origin = $this->getReference(LoadAccompanyingPeriodOrigin::ACCOMPANYING_PERIOD_ORIGIN, AccompanyingPeriod\Origin::class);
$accompanyingPeriod->setOrigin($origin); $accompanyingPeriod->setOrigin($origin);
$accompanyingPeriod->setIntensity('regular'); $accompanyingPeriod->setIntensity('regular');
$accompanyingPeriod->setAddressLocation($this->createAddress()); $accompanyingPeriod->setAddressLocation($this->createAddress());
@ -472,7 +472,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
{ {
$ref = LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)]; $ref = LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)];
return $this->getReference($ref, null); return $this->getReference($ref, PostalCode::class);
} }
private function getRandomSocialIssue(): SocialIssue private function getRandomSocialIssue(): SocialIssue

View File

@ -12,7 +12,9 @@ declare(strict_types=1);
namespace Chill\PersonBundle\DataFixtures\ORM; namespace Chill\PersonBundle\DataFixtures\ORM;
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup; use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
use Chill\MainBundle\Entity\PermissionsGroup;
use Chill\MainBundle\Entity\RoleScope; use Chill\MainBundle\Entity\RoleScope;
use Chill\MainBundle\Entity\Scope;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Chill\PersonBundle\Security\Authorization\PersonVoter; use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
@ -33,8 +35,8 @@ class LoadPersonACL extends AbstractFixture implements OrderedFixtureInterface
public function load(ObjectManager $manager): void public function load(ObjectManager $manager): void
{ {
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) { foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
$permissionsGroup = $this->getReference($permissionsGroupRef, null); $permissionsGroup = $this->getReference($permissionsGroupRef, PermissionsGroup::class);
$scopeSocial = $this->getReference('scope_social', null); $scopeSocial = $this->getReference('scope_social', Scope::class);
// create permission group // create permission group
switch ($permissionsGroup->getName()) { switch ($permissionsGroup->getName()) {

View File

@ -14,6 +14,7 @@ namespace Chill\PersonBundle\DataFixtures\ORM;
use Chill\MainBundle\DataFixtures\ORM\LoadUsers; use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\DataFixtures\Helper\PersonRandomHelper; use Chill\PersonBundle\DataFixtures\Helper\PersonRandomHelper;
use Chill\PersonBundle\Entity\Relationships\Relation;
use Chill\PersonBundle\Entity\Relationships\Relationship; use Chill\PersonBundle\Entity\Relationships\Relationship;
use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface; use Doctrine\Common\DataFixtures\DependentFixtureInterface;
@ -46,7 +47,7 @@ class LoadRelationships extends Fixture implements DependentFixtureInterface
->setFromPerson($this->getRandomPerson($this->em)) ->setFromPerson($this->getRandomPerson($this->em))
->setToPerson($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), null)) random_int(0, \count(LoadRelations::RELATIONS) - 1), Relation::class))
->setReverse((bool) random_int(0, 1)) ->setReverse((bool) random_int(0, 1))
->setCreatedBy($user) ->setCreatedBy($user)
->setUpdatedBy($user) ->setUpdatedBy($user)
@ -74,6 +75,6 @@ class LoadRelationships extends Fixture implements DependentFixtureInterface
{ {
$userRef = array_rand(LoadUsers::$refs); $userRef = array_rand(LoadUsers::$refs);
return $this->getReference($userRef, null); return $this->getReference($userRef, User::class);
} }
} }

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\ReportBundle\DataFixtures\ORM; namespace Chill\ReportBundle\DataFixtures\ORM;
use Chill\CustomFieldsBundle\Entity\CustomField; use Chill\CustomFieldsBundle\Entity\CustomField;
use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -74,7 +75,7 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
->setOptions($cFType['options']) ->setOptions($cFType['options'])
->setName(['fr' => "CustomField {$i}"]) ->setName(['fr' => "CustomField {$i}"])
->setOrdering(random_int(0, 1000) / 1000) ->setOrdering(random_int(0, 1000) / 1000)
->setCustomFieldsGroup($this->getReference('cf_group_report_'.random_int(0, 3), null)); ->setCustomFieldsGroup($this->getReference('cf_group_report_'.random_int(0, 3), CustomFieldsGroup::class));
$manager->persist($customField); $manager->persist($customField);
} }
@ -87,7 +88,7 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
private function createExpectedFields(ObjectManager $manager) private function createExpectedFields(ObjectManager $manager)
{ {
// report logement // report logement
$reportLogement = $this->getReference('cf_group_report_logement', null); $reportLogement = $this->getReference('cf_group_report_logement', CustomFieldsGroup::class);
$houseTitle = (new CustomField()) $houseTitle = (new CustomField())
->setSlug('house_title') ->setSlug('house_title')
@ -143,7 +144,7 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
$manager->persist($descriptionLogement); $manager->persist($descriptionLogement);
// report problems // report problems
$reportEducation = $this->getReference('cf_group_report_education', null); $reportEducation = $this->getReference('cf_group_report_education', CustomFieldsGroup::class);
$title = (new CustomField()) $title = (new CustomField())
->setSlug('title') ->setSlug('title')

View File

@ -13,7 +13,9 @@ namespace Chill\ReportBundle\DataFixtures\ORM;
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup; use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes; use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
use Chill\MainBundle\Entity\PermissionsGroup;
use Chill\MainBundle\Entity\RoleScope; use Chill\MainBundle\Entity\RoleScope;
use Chill\MainBundle\Entity\Scope;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -32,11 +34,11 @@ class LoadReportACL extends AbstractFixture implements OrderedFixtureInterface
public function load(ObjectManager $manager): void public function load(ObjectManager $manager): void
{ {
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) { foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
$permissionsGroup = $this->getReference($permissionsGroupRef, null); $permissionsGroup = $this->getReference($permissionsGroupRef, PermissionsGroup::class);
printf("processing permission group %s \n", $permissionsGroup->getName()); printf("processing permission group %s \n", $permissionsGroup->getName());
foreach (LoadScopes::$references as $scopeRef) { foreach (LoadScopes::$references as $scopeRef) {
$scope = $this->getReference($scopeRef, null); $scope = $this->getReference($scopeRef, Scope::class);
printf("processing scope %s \n", $scope->getName()['en']); printf("processing scope %s \n", $scope->getName()['en']);
// create permission group // create permission group
switch ($permissionsGroup->getName()) { switch ($permissionsGroup->getName()) {

View File

@ -12,8 +12,11 @@ declare(strict_types=1);
namespace Chill\ReportBundle\DataFixtures\ORM; namespace Chill\ReportBundle\DataFixtures\ORM;
use Chill\CustomFieldsBundle\Entity\CustomField; use Chill\CustomFieldsBundle\Entity\CustomField;
use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes; use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
use Chill\MainBundle\DataFixtures\ORM\LoadUsers; use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Chill\ReportBundle\Entity\Report; use Chill\ReportBundle\Entity\Report;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
@ -60,9 +63,9 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
if (null !== $charline) { if (null !== $charline) {
$report = (new Report()) $report = (new Report())
->setPerson($charline) ->setPerson($charline)
->setCFGroup($this->getReference('cf_group_report_logement', null)) ->setCFGroup($this->getReference('cf_group_report_logement', CustomFieldsGroup::class))
->setDate(new \DateTime('2015-01-05')) ->setDate(new \DateTime('2015-01-05'))
->setScope($this->getReference('scope_social', null)); ->setScope($this->getReference('scope_social', Scope::class));
$this->fillReport($report); $this->fillReport($report);
$manager->persist($report); $manager->persist($report);
@ -81,8 +84,8 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
->setPerson($person) ->setPerson($person)
->setCFGroup( ->setCFGroup(
random_int(0, 10) > 5 ? random_int(0, 10) > 5 ?
$this->getReference('cf_group_report_logement', null) : $this->getReference('cf_group_report_logement', CustomFieldsGroup::class) :
$this->getReference('cf_group_report_education', null) $this->getReference('cf_group_report_education', CustomFieldsGroup::class)
) )
->setScope($this->getScopeRandom()); ->setScope($this->getScopeRandom());
$this->fillReport($report); $this->fillReport($report);
@ -95,7 +98,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
// setUser // setUser
$usernameRef = array_rand(LoadUsers::$refs); $usernameRef = array_rand(LoadUsers::$refs);
$report->setUser( $report->setUser(
$this->getReference($usernameRef, null) $this->getReference($usernameRef, User::class)
); );
// set date if null // set date if null
@ -214,7 +217,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
{ {
$ref = LoadScopes::$references[array_rand(LoadScopes::$references)]; $ref = LoadScopes::$references[array_rand(LoadScopes::$references)];
return $this->getReference($ref, null); return $this->getReference($ref, Scope::class);
} }
/** /**

View File

@ -13,7 +13,9 @@ namespace Chill\TaskBundle\DataFixtures\ORM;
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup; use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes; use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
use Chill\MainBundle\Entity\PermissionsGroup;
use Chill\MainBundle\Entity\RoleScope; use Chill\MainBundle\Entity\RoleScope;
use Chill\MainBundle\Entity\Scope;
use Chill\TaskBundle\Security\Authorization\TaskVoter; use Chill\TaskBundle\Security\Authorization\TaskVoter;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
@ -33,10 +35,10 @@ class LoadTaskACL extends AbstractFixture implements OrderedFixtureInterface
public function load(ObjectManager $manager): void public function load(ObjectManager $manager): void
{ {
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) { foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
$permissionsGroup = $this->getReference($permissionsGroupRef, null); $permissionsGroup = $this->getReference($permissionsGroupRef, PermissionsGroup::class);
foreach (LoadScopes::$references as $scopeRef) { foreach (LoadScopes::$references as $scopeRef) {
$scope = $this->getReference($scopeRef, null); $scope = $this->getReference($scopeRef, Scope::class);
// create permission group // create permission group
switch ($permissionsGroup->getName()) { switch ($permissionsGroup->getName()) {
case 'social': case 'social':

View File

@ -14,6 +14,7 @@ namespace Chill\ThirdPartyBundle\DataFixtures\ORM;
use Chill\MainBundle\DataFixtures\ORM\LoadCenters; 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\Center;
use Chill\MainBundle\Entity\PostalCode; use Chill\MainBundle\Entity\PostalCode;
use Chill\ThirdPartyBundle\Entity\ThirdParty; use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Bundle\FixturesBundle\Fixture;
@ -70,10 +71,10 @@ class LoadThirdParty extends Fixture implements DependentFixtureInterface
$number = random_int(1, \count($references)); $number = random_int(1, \count($references));
if (1 === $number) { if (1 === $number) {
yield $this->getReference($references[array_rand($references)], null); yield $this->getReference($references[array_rand($references)], Center::class);
} else { } else {
foreach (array_rand($references, $number) as $index) { foreach (array_rand($references, $number) as $index) {
yield $this->getReference($references[$index], null); yield $this->getReference($references[$index], Center::class);
} }
} }
} }
@ -82,7 +83,7 @@ class LoadThirdParty extends Fixture implements DependentFixtureInterface
{ {
$ref = LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)]; $ref = LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)];
return $this->getReference($ref, null); return $this->getReference($ref, PostalCode::class);
} }
private function getThirdParties(): ObjectSet private function getThirdParties(): ObjectSet