getEncoder() публичный Метод

Get encoder.
public getEncoder ( ) : Neomerx\JsonApi\Contracts\Encoder\EncoderInterface | null
Результат Neomerx\JsonApi\Contracts\Encoder\EncoderInterface | null
 /**
  * @inheritdoc
  */
 public function getContent(Exception $exception)
 {
     $converter = $this->converter;
     $errors = $converter($exception);
     $encoder = $this->codecMatcher->getEncoder();
     $content = is_array($errors) === true ? $encoder->encodeErrors($errors) : $encoder->encodeError($errors);
     return $content;
 }
Пример #2
0
 /**
  * @param object                                                             $resource
  * @param array<string,\Neomerx\JsonApi\Contracts\Schema\LinkInterface>|null $links
  * @param mixed                                                              $meta
  *
  * @return Response
  */
 protected function getCreatedResponse($resource, $links = null, $meta = null)
 {
     $parameters = $this->getParameters();
     $encoder = $this->codecMatcher->getEncoder();
     $outputMediaType = $this->codecMatcher->getEncoderRegisteredMatchedType();
     $content = $encoder->encode($resource, $links, $meta, $parameters);
     $urlPrefix = $encoder->getEncoderOptions() === null ? null : $encoder->getEncoderOptions()->getUrlPrefix();
     $location = $urlPrefix . $this->schemaContainer->getSchema($resource)->getSelfSubLink($resource)->getSubHref();
     return $this->responses->getCreatedResponse($location, $outputMediaType, $content, $this->supportedExtensions);
 }
Пример #3
0
 /**
  * @param object                                                             $resource
  * @param array<string,\Neomerx\JsonApi\Contracts\Schema\LinkInterface>|null $links
  * @param mixed                                                              $meta
  *
  * @return Response
  */
 protected function getCreatedResponse($resource, $links = null, $meta = null)
 {
     $integration = $this->getIntegration();
     $parameters = $this->getParameters();
     $encoder = $this->codecMatcher->getEncoder();
     $outputMediaType = $this->codecMatcher->getEncoderRegisteredMatchedType();
     $links === null ?: $encoder->withLinks($links);
     $meta === null ?: $encoder->withMeta($meta);
     $content = $encoder->encodeData($resource, $parameters);
     /** @var ResponsesInterface $responses */
     $responses = $integration->getFromContainer(ResponsesInterface::class);
     /** @var ContainerInterface $schemaContainer */
     $schemaContainer = $integration->getFromContainer(ContainerInterface::class);
     $config = $integration->getFromContainer(C::class);
     $urlPrefix = isset($config[C::JSON][C::JSON_URL_PREFIX]) === true ? $config[C::JSON][C::JSON_URL_PREFIX] : null;
     $location = $urlPrefix . $schemaContainer->getSchema($resource)->getSelfSubLink($resource)->getSubHref();
     return $responses->getCreatedResponse($location, $outputMediaType, $content, $this->supportedExtensions);
 }