Get media type that was registered for matched encoder.
public getEncoderRegisteredMatchedType ( ) : Neomerx\JsonApi\Contracts\Http\Headers\MediaTypeInterface | null | ||
Результат | Neomerx\JsonApi\Contracts\Http\Headers\MediaTypeInterface | null |
/** * @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); }
/** * @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); }