public function makeAll(&$demoDataHelper) { assert('$demoDataHelper instanceof DemoDataHelper'); assert('$demoDataHelper->isSetRange("User")'); $missions = array(); foreach (self::getMissionData() as $randomMissionData) { $postData = array(); $mission = new Mission(); $mission->setScenario('importModel'); $mission->status = Mission::STATUS_AVAILABLE; $mission->owner = $demoDataHelper->getRandomByModelName('User'); $mission->createdByUser = $mission->owner; $mission->description = $randomMissionData['description']; $mission->reward = $randomMissionData['reward']; //Add some comments foreach ($randomMissionData['comments'] as $commentDescription) { $comment = new Comment(); $comment->setScenario('importModel'); $comment->createdByUser = $demoDataHelper->getRandomByModelName('User'); $comment->description = $commentDescription; $mission->comments->add($comment); } $mission->addPermissions(Group::getByName(Group::EVERYONE_GROUP_NAME), Permission::READ_WRITE); $saved = $mission->save(); assert('$saved'); $mission = Mission::getById($mission->id); ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($mission, Group::getByName(Group::EVERYONE_GROUP_NAME)); $mission->save(); $missions[] = $mission->id; } $demoDataHelper->setRangeByModelName('Mission', $missions[0], $missions[count($missions) - 1]); }