コード例 #1
0
ファイル: Mapper.php プロジェクト: GasimGasimzada/spot2
 public function testGetCustomEntityMapper()
 {
     $mapper = test_spot_mapper('SpotTest\\Entity\\Event');
     $this->assertInstanceOf(Entity\Event::mapper(), $mapper);
     $query = $mapper->testQuery();
     $this->assertInstanceOf('Spot\\Query', $query);
 }
コード例 #2
0
 private function jsonToEvent($json)
 {
     $event = new \Entity\Event();
     if (!isset($json->event)) {
         throw new \Exception('Ocorrência em Branco');
     }
     if (!isset($json->type)) {
         throw new \Exception('Tipo em Branco');
     }
     if (!isset($json->time)) {
         throw new \Exception('Tekpo em Branco');
     }
     if (isset($json->id)) {
         $event->setId($json->id);
     }
     $event->setDescription($json->event);
     $event->setType($json->type);
     $event->setTime($json->time);
     $event->setEquipmentId($json->equipment_id);
     $event->setUserId(self::USER_ID);
     $event->setTimestamp(time());
     return $event;
 }
コード例 #3
0
 private function eventFactory($result)
 {
     $events = array();
     if (is_array($result)) {
         if (count($result) > 0) {
             foreach ($result as $value) {
                 $event = new \Entity\Event();
                 $event->setId($value['event_id']);
                 $event->setDescription($value['description']);
                 $event->setEquipmentId($value['equipment_id']);
                 $event->setTime($value['time']);
                 $event->setTimestamp($value['create_timestamp']);
                 $event->setUserId($value['user_id']);
                 $event->setType($value['type']);
                 $events[] = $event;
             }
         }
     }
     return $events;
 }