コード例 #1
0
ファイル: LoadIncidentData.php プロジェクト: hogosha/hogosha
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $dataSets = [['name' => 'Mysql is down', 'status' => 0, 'user' => 'user-admin', 'description' => 'Here you should put some description in order to inform our users.'], ['name' => 'Mysql is in a strange state', 'status' => 1, 'readable_status' => '', 'user' => 'user-admin', 'description' => 'Here you should put some description in order to inform our users.'], ['name' => 'Mysql is ok now', 'status' => 2, 'user' => 'user-admin', 'description' => 'Here you should put some description in order to inform our users.']];
     foreach ($dataSets as $data) {
         $today = Carbon::now();
         $incident = new Incident();
         $incident->setName($data['name']);
         $incident->setStatus($data['status']);
         $incident->setService($this->getReference('service-0'));
         $incident->setCreatedAt($today);
         $incident->setDescription($data['description']);
         $incident->setUser($this->getReference($data['user']));
         $manager->persist($incident);
     }
     $manager->flush();
 }