getQueryFactory() ->createFindAllQueryByRequest($this->getPsrRequest()); $collection = $this->getMediaRelationService() ->findRelations($query) ->jsonSerialize(); $this->setSuccessJsonResponse($collection); } catch (Throwable $exception) { $this->logError(sprintf('Error getting media relation: %s, ', $exception->getMessage())); $this->setErrorJsonResponse($exception->getMessage(), $exception->getCode()); } } private function getMediaRelationService(): MediaRelationService { return $this->getServiceLocator()->get(MediaRelationService::class); } private function getQueryFactory(): QueryFactory { return $this->getServiceLocator()->get(QueryFactory::class); } }