/**
  * @inheritdoc
  */
 protected function getMediaType()
 {
     $type = $this->service->getApi()->getCodecMatcher()->getEncoderRegisteredMatchedType();
     if (!$type instanceof MediaTypeInterface) {
         throw new RuntimeException('No matching media type for encoded JSON-API response.');
     }
     return $type;
 }
Exemplo n.º 2
0
 /**
  * @param int|null $page
  * @param int $perPage
  * @param array $parameters
  * @param array|object|null $meta
  * @return LinkInterface|null
  */
 protected function createLink($page, $perPage, array $parameters = [], $meta = null)
 {
     if (!is_int($page)) {
         return null;
     }
     $strategy = $this->service->getApi()->getPagingStrategy();
     return $this->linkTo()->current(array_merge($parameters, [QueryParametersParserInterface::PARAM_PAGE => [$strategy->getPage() => $page, $strategy->getPerPage() => $perPage]]), $meta);
 }
Exemplo n.º 3
0
 /**
  * @return array
  */
 protected function getParams()
 {
     $encodingParameters = $this->service->getRequest()->getParameters();
     return (array) $encodingParameters->getPaginationParameters();
 }
 /**
  * @param ResourceIdentifierInterface $identifier
  * @return Model
  */
 protected function findRelated(ResourceIdentifierInterface $identifier)
 {
     $model = $this->service->getApi()->getStore()->find($identifier);
     if (!$model instanceof Model) {
         throw new RuntimeException('Expecting a related resource to be an Eloquent model');
     }
     return $model;
 }