Пример #1
0
 /**
  * Gets an log record by the data from db
  *
  * @param    array      $data   Array
  * @return   LogRecord  Returns LogRecord object
  */
 private function getLogRecord($data)
 {
     $record = new LogRecord($data['_id']);
     $record->setAccountid(isset($data['accountid']) ? $data['accountid'] : null)->setEmail(isset($data['email']) ? $data['email'] : null)->setEnvid(isset($data['envid']) ? $data['envid'] : null)->setIp(isset($data['ip']) ? $data['ip'] : null)->setMessage(isset($data['message']) ? $data['message'] : null)->setUserid(isset($data['userid']) ? $data['userid'] : null);
     if (isset($data['time'])) {
         $time = new \DateTime(null, new \DateTimeZone('UTC'));
         $time->setTimestamp($data['time']->sec);
         $record->setTime($time);
     }
     if (isset($data['datatype'])) {
         $kvr = new KeyValueRecord($data['datatype']);
         foreach ($data['data'] as $prop => $val) {
             $kvr->{$prop} = $val;
         }
         $record->setData($kvr);
     }
     if (!empty($data['tags']) && is_array($data['tags'])) {
         $record->setTags(new AuditLogTags($data['tags']));
     }
     return $record;
 }