Lines
97.14%
34 / 35
Methods
50.00%
1 / 2
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| readResponse | 96.87% | 31 / 32 | 0.00% | 0 / 1 | 4 | ||
| [BO\Zmsbackend\Api\BaseController] __invoke | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 1 | ||
| 16 | class ProcessLog extends \BO\Zmsbackend\Api\BaseController | |
| 17 | { | |
| 18 | /** | |
| 19 | * @SuppressWarnings(Param) | |
| 20 | * @return \Psr\Http\Message\ResponseInterface | |
| 21 | */ | |
| 22 | #[\Override] | |
| 23 | public function readResponse( | |
| 24 | \Psr\Http\Message\RequestInterface $request, | |
| 25 | \Psr\Http\Message\ResponseInterface $response, | |
| 26 | array $args | |
| 27 | ) { | |
| 28 | (new \BO\Zmsbackend\Helper\User($request))->checkPermissions('logs'); | |
| 29 | $searchQuery = Validator::param('searchQuery')->isString()->setDefault(null)->getValue(); | |
| 30 | $service = Validator::param('service')->isString()->setDefault(null)->getValue(); | |
| 31 | $provider = Validator::param('provider')->isString()->setDefault(null)->getValue(); | |
| 32 | $date = Validator::param('date')->isString()->setDefault(null)->getValue(); | |
| 33 | $userAction = Validator::param('userAction')->isNumber()->setDefault(0)->getValue(); | |
| 34 | $requestedPage = (int) Validator::param('page')->isNumber()->setDefault(1)->getValue(); | |
| 35 | $requestedResultsPerPage = (int) Validator::param('perPage') | |
| 36 | ->isNumber() | |
| 37 | ->setDefault(SearchPagination::DEFAULT_RESULTS_PER_PAGE) | |
| 38 | ->getValue(); | |
| 39 | $page = SearchPagination::normalizePage($requestedPage); | |
| 40 | $resultsPerPage = SearchPagination::normalizeResultsPerPage($requestedResultsPerPage); | |
| 41 | $scopeIds = Validator::param('scopeIds')->isString()->setDefault(null)->getValue(); | |
| 42 | ||
| 43 | $resolvedScopeIds = null; | |
| 44 | if ($scopeIds !== null && $scopeIds !== '') { | |
| 45 | $resolvedScopeIds = array_values(array_filter(array_map('intval', explode(',', $scopeIds)))); | |
| 46 | } | |
| 47 | ||
| 48 | $logList = (new Query())->readByProcessData( | |
| 49 | urldecode((string) $searchQuery), | |
| 50 | $service, | |
| 51 | $provider, | |
| 52 | $date ? new DateTime($date) : null, | |
| 53 | $userAction, | |
| 54 | $page, | |
| 55 | $resultsPerPage, | |
| 56 | $resolvedScopeIds | |
| 57 | ); | |
| 58 | ||
| 59 | $message = \BO\Zmsbackend\Api\Response\Message::create($request); | |
| 60 | $message->data = $logList; | |
| 61 | ||
| 62 | $response = Render::withLastModified($response, time(), '0'); | |
| 63 | $response = Render::withJson($response, $message, 200); | |
| 64 | return $response; | |
| 65 | } | |
| 66 | } |
Inherited from BO\Zmsbackend\Api\BaseController
| 20 | public function __invoke(RequestInterface $request, ResponseInterface $response, array $args) | |
| 21 | { | |
| 22 | $request = $this->initRequest($request); | |
| 23 | $noCacheResponse = \BO\Slim\Render::withLastModified($response, time(), '0'); | |
| 24 | return $this->readResponse($request, $noCacheResponse, $args); | |
| 25 | } |