mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-01 04:23:49 +00:00
An activity may have multiple reasons
The relationship between Activity and Reasons is now many-to-many. Some improvement in show activity layout. refs #4 #7
This commit is contained in:
@@ -84,9 +84,15 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface, C
|
||||
*
|
||||
* @return \Chill\ActivityBundle\Entity\ActivityReason
|
||||
*/
|
||||
private function getRandomActivityReason()
|
||||
private function getRandomActivityReason(array $excludingIds)
|
||||
{
|
||||
$reasonRef = LoadActivityReason::$references[array_rand(LoadActivityReason::$references)];
|
||||
|
||||
if (in_array($this->getReference($reasonRef)->getId(), $excludingIds)) {
|
||||
// we have a reason which should be excluded. Find another...
|
||||
return $this->getRandomActivityReason($excludingIds);
|
||||
}
|
||||
|
||||
return $this->getReference($reasonRef);
|
||||
}
|
||||
|
||||
@@ -109,10 +115,17 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface, C
|
||||
->setDate($this->faker->dateTimeThisYear())
|
||||
->setDurationTime($this->faker->dateTime(36000))
|
||||
->setType($this->getRandomActivityType())
|
||||
->setReason($this->getRandomActivityReason())
|
||||
->setScope($this->getRandomScope())
|
||||
->setAttendee($this->faker->boolean())
|
||||
->setRemark('A remark');
|
||||
|
||||
$usedId = array();
|
||||
for ($i = 0; $i < rand(0, 4); $i++) {
|
||||
$reason = $this->getRandomActivityReason($usedId);
|
||||
$usedId[] = $reason->getId();
|
||||
$activity->addReason($reason);
|
||||
}
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user