/** * @param array $params * @return mixed */ public function export(array $params = []) { $params['rows'] = $this->loggerService->getOption(LoggerService::OPTION_EXPORTABLE_QUANTITY); $params['till'] = (new DateTimeImmutable())->sub(new DateInterval($this->loggerService->getOption(LoggerService::OPTION_EXPORTABLE_PERIOD))); $data = $this->loggerService->searchInstances($params); return $data['data']; }
/** * Load json data with results * dates for GUI should be in user time zone */ public function search() { $results = $this->loggerService->searchInstances($this->getRequestParameters()); // prettify data array_walk($results['data'], function (&$row) { $date = new DateTime($row['occurred'], new \DateTimeZone('UTC')); $row['occurred'] = tao_helpers_Date::displayeDate($date->getTimestamp()); $row['raw'] = array_map(null, $row); $row['id'] = 'identifier-' . $row['id']; $eventNameChunks = explode('\\', $row['event_name']); $row['event_name'] = array_pop($eventNameChunks); $row['user_id'] = tao_helpers_Uri::getUniqueId($row['user_id']); $roles = explode(',', $row['user_roles']); foreach ($roles as &$role) { $role = tao_helpers_Uri::getUniqueId($role); } $row['user_roles'] = join(', ', $roles); }); $results['page'] = $this->getRequestParameter('page'); $results['total'] = ceil($results['records'] / $this->getRequestParameter('rows')); $this->returnJson($results, 200); }