/** * @param QueryRequest $qr * @return array * @throws TypeNotValidException * @throws ValidationFailedException */ public function getResults(QueryRequest $qr) { // if the query request is cached then call the cached version! $configurations = ["time" => $qr->getConfig()->getExecutionLimit(), "rows" => $qr->getConfig()->getQueryLimit(), "chartType" => $qr->getConfig()->getTypeOfChart(), "offset" => $qr->getConfig()->getOffset(), "connection" => $qr->getConfig()->getDatabaseConnection(), "cronExpression" => $qr->getCronExpression()]; if ($this->hasDependency(LiveStrategy::DEPENDENCY_NAME)) { try { $dependencies = $this->getDependencies(); /** @var QueryValidatorService $queryValidator */ $queryValidator = $dependencies[LiveStrategy::DEPENDENCY_NAME]; $query = $qr->getQuery()->getQuery(); $queryValidator->isValidQuery($query, $configurations["connection"]); $results = $queryValidator->validateQueryExecution($query, $configurations); return $results; } catch (OffLimitsException $e) { $exception = new ValidationFailedException("Query validation has failed. {$e->getMessage()}", $e->getCode(), $e); throw $exception; } } throw new TypeNotValidException(ExceptionMessage::DEPENDENCY_NOT_AVAILABLE(", QueryValidator was absent"), 500); }