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

@@ -74,7 +74,7 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
->setOptions($cFType['options'])
->setName(['fr' => "CustomField {$i}"])
->setOrdering(random_int(0, 1000) / 1000)
->setCustomFieldsGroup($this->getReference('cf_group_report_'.random_int(0, 3)));
->setCustomFieldsGroup($this->getReference('cf_group_report_'.random_int(0, 3), null));
$manager->persist($customField);
}
@@ -87,7 +87,7 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
private function createExpectedFields(ObjectManager $manager)
{
// report logement
$reportLogement = $this->getReference('cf_group_report_logement');
$reportLogement = $this->getReference('cf_group_report_logement', null);
$houseTitle = (new CustomField())
->setSlug('house_title')
@@ -143,7 +143,7 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
$manager->persist($descriptionLogement);
// report problems
$reportEducation = $this->getReference('cf_group_report_education');
$reportEducation = $this->getReference('cf_group_report_education', null);
$title = (new CustomField())
->setSlug('title')

View File

@@ -32,11 +32,11 @@ class LoadReportACL extends AbstractFixture implements OrderedFixtureInterface
public function load(ObjectManager $manager): void
{
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
$permissionsGroup = $this->getReference($permissionsGroupRef);
$permissionsGroup = $this->getReference($permissionsGroupRef, null);
printf("processing permission group %s \n", $permissionsGroup->getName());
foreach (LoadScopes::$references as $scopeRef) {
$scope = $this->getReference($scopeRef);
$scope = $this->getReference($scopeRef, null);
printf("processing scope %s \n", $scope->getName()['en']);
// create permission group
switch ($permissionsGroup->getName()) {

View File

@@ -60,9 +60,9 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
if (null !== $charline) {
$report = (new Report())
->setPerson($charline)
->setCFGroup($this->getReference('cf_group_report_logement'))
->setCFGroup($this->getReference('cf_group_report_logement', null))
->setDate(new \DateTime('2015-01-05'))
->setScope($this->getReference('scope_social'));
->setScope($this->getReference('scope_social', null));
$this->fillReport($report);
$manager->persist($report);
@@ -81,8 +81,8 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
->setPerson($person)
->setCFGroup(
random_int(0, 10) > 5 ?
$this->getReference('cf_group_report_logement') :
$this->getReference('cf_group_report_education')
$this->getReference('cf_group_report_logement', null) :
$this->getReference('cf_group_report_education', null)
)
->setScope($this->getScopeRandom());
$this->fillReport($report);
@@ -95,7 +95,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
// setUser
$usernameRef = array_rand(LoadUsers::$refs);
$report->setUser(
$this->getReference($usernameRef)
$this->getReference($usernameRef, null)
);
// set date if null
@@ -214,7 +214,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
{
$ref = LoadScopes::$references[array_rand(LoadScopes::$references)];
return $this->getReference($ref);
return $this->getReference($ref, null);
}
/**