Add second parameter to add-, get-, hasReference() methods in fixture classes

This commit is contained in:
2024-11-28 12:44:14 +01:00
parent 0ac49d1fde
commit 19e6ceba28
27 changed files with 61 additions and 59 deletions

View File

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

View File

@@ -69,7 +69,8 @@ class LoadAddressReferences extends AbstractFixture implements ContainerAwareInt
$ar->setStreetNumber((string) random_int(0, 199));
$ar->setPoint($this->getRandomPoint());
$ar->setPostcode($this->getReference(
LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)]
LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)],
null
));
$ar->setMunicipalityCode($ar->getPostcode()->getCode());

View File

@@ -30,8 +30,8 @@ class LoadGroupCenters extends AbstractFixture implements OrderedFixtureInterfac
foreach (LoadCenters::$refs as $centerRef) {
foreach (LoadPermissionsGroup::$refs as $permissionGroupRef) {
$GroupCenter = new GroupCenter();
$GroupCenter->setCenter($this->getReference($centerRef));
$GroupCenter->setPermissionsGroup($this->getReference($permissionGroupRef));
$GroupCenter->setCenter($this->getReference($centerRef, null));
$GroupCenter->setPermissionsGroup($this->getReference($permissionGroupRef, null));
$manager->persist($GroupCenter);

View File

@@ -59,7 +59,7 @@ class LoadPermissionsGroup extends AbstractFixture implements OrderedFixtureInte
$permissionGroup->setName($new['name']);
foreach ($new['role_scopes'] as $roleScopeRef) {
$permissionGroup->addRoleScope($this->getReference($roleScopeRef));
$permissionGroup->addRoleScope($this->getReference($roleScopeRef, null));
}
$manager->persist($permissionGroup);

View File

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

View File

@@ -55,8 +55,8 @@ class LoadRoleScopes extends AbstractFixture implements OrderedFixtureInterface
foreach (LoadScopes::$references as $scopeReference) {
$roleScope = new RoleScope();
$roleScope->setRole($key)
->setScope($this->getReference($scopeReference));
$reference = 'role_scope_'.$key.'_'.$this->getReference($scopeReference)->getName()['en'];
->setScope($this->getReference($scopeReference, null));
$reference = 'role_scope_'.$key.'_'.$this->getReference($scopeReference, null)->getName()['en'];
echo "Creating {$reference} \n";
$this->addReference($reference, $roleScope);
$manager->persist($roleScope);

View File

@@ -80,7 +80,7 @@ class LoadUsers extends AbstractFixture implements ContainerAwareInterface, Orde
->setEmail(sprintf('%s@chill.social', \str_replace(' ', '', (string) $username)));
foreach ($params['groupCenterRefs'] as $groupCenterRef) {
$user->addGroupCenter($this->getReference($groupCenterRef));
$user->addGroupCenter($this->getReference($groupCenterRef, null));
}
echo 'Creating user '.$username."... \n";