Create encoder.
public createEncoder ( Neomerx\JsonApi\Contracts\Schema\ContainerInterface $container, Neomerx\JsonApi\Encoder\EncoderOptions $encoderOptions = null ) : Neomerx\JsonApi\Contracts\Encoder\EncoderInterface | ||
$container | Neomerx\JsonApi\Contracts\Schema\ContainerInterface | |
$encoderOptions | Neomerx\JsonApi\Encoder\EncoderOptions | |
Résultat | Neomerx\JsonApi\Contracts\Encoder\EncoderInterface |
/** * @return Generator */ private function getEncoders() { /** @var array $encoder */ foreach ($this->encoders as $mediaType => $encoder) { $closure = function () use($encoder) { $options = $encoder[static::OPTIONS]; $depth = $encoder[static::DEPTH]; $encOptions = new EncoderOptions($options, $this->getUrlPrefix(), $depth); return $this->factory->createEncoder($this->getSchemas(), $encOptions); }; (yield $mediaType => $closure); } }
/** * @param FactoryInterface $factory * @param ContainerInterface $container * @param EncoderOptions $encoderOptions * @param array $config * * @return Closure */ private function getEncoderClosure(FactoryInterface $factory, ContainerInterface $container, EncoderOptions $encoderOptions, array $config) { return function () use($factory, $container, $encoderOptions, $config) { $isShowVer = $this->getValue($config, C::JSON, C::JSON_IS_SHOW_VERSION, C::JSON_IS_SHOW_VERSION_DEFAULT); $versionMeta = $this->getValue($config, C::JSON, C::JSON_VERSION_META, null); $encoder = $factory->createEncoder($container, $encoderOptions); $isShowVer === false ?: $encoder->withJsonApiVersion($versionMeta); return $encoder; }; }