Inheritance: extends Neomerx\JsonApi\Contracts\Document\DocumentFactoryInterface, extends Neomerx\JsonApi\Contracts\Encoder\Parser\ParserFactoryInterface, extends Neomerx\JsonApi\Contracts\Encoder\Stack\StackFactoryInterface, extends Neomerx\JsonApi\Contracts\Encoder\Handlers\HandlerFactoryInterface, extends Neomerx\JsonApi\Contracts\Http\HttpFactoryInterface, extends Neomerx\JsonApi\Contracts\Schema\SchemaFactoryInterface, extends Psr\Log\LoggerAwareInterface
Esempio n. 1
0
 /**
  * @param object     $resource
  * @param string     $key
  * @param string     $prefix
  * @param string     $name
  * @param null|mixed $meta
  * @param bool       $treatAsHref
  *
  * @return EncoderInterface
  */
 private function getRelationshipLink($resource, $key, $prefix, $name, $meta = null, $treatAsHref = false)
 {
     $parentSubLink = $this->container->getSchema($resource)->getSelfSubLink($resource);
     $selfHref = $parentSubLink->getSubHref() . $prefix . '/' . $name;
     $links = [$key => $this->factory->createLink($selfHref, $meta, $treatAsHref)];
     return $this->withLinks($links);
 }
 /**
  * @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);
     }
 }
Esempio n. 3
0
 /**
  * @param object|array|Iterator|null       $data
  * @param DataAnalyzerInterface            $analyzer
  * @param EncodingParametersInterface|null $parameters
  *
  * @return EncodingParametersInterface
  */
 private function getEncodingParameters($data, DataAnalyzerInterface $analyzer, $parameters = null)
 {
     /** @var bool $isDataEmpty */
     /** @var SchemaProviderInterface $schema */
     list($isDataEmpty, , $schema) = $analyzer->analyze($data);
     if ($isDataEmpty === true) {
         return $this->factory->createEncodingParameters();
     } elseif ($parameters !== null && $parameters->getIncludePaths() !== null) {
         return $parameters;
     } else {
         $includePaths = $schema->getIncludePaths();
         $fieldSets = $parameters === null ? null : $parameters->getFieldSets();
         return $this->factory->createEncodingParameters($includePaths, $fieldSets);
     }
 }
 /**
  * @inheritdoc
  */
 public function createResourceObject($resource, $isOriginallyArrayed, $attributeKeysFilter = null)
 {
     $attributeKeysFilter = [];
     return $this->factory->createResourceObject($this, $resource, $isOriginallyArrayed, $attributeKeysFilter);
 }
 /**
  * @param SchemaProviderInterface $schema
  *
  * @return SchemaProviderInterface
  */
 protected function getSchemaAdapter(SchemaProviderInterface $schema)
 {
     return $this->factory->createResourceIdentifierSchemaAdapter($schema);
 }
 /**
  * @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;
     };
 }
Esempio n. 7
0
 /**
  * @param ContainerInterface               $container
  * @param EncodingParametersInterface|null $parameters
  *
  * @return ParametersAnalyzerInterface
  */
 private function createParametersAnalyzer(ContainerInterface $container, EncodingParametersInterface $parameters = null)
 {
     return $this->factory->createParametersAnalyzer($parameters === null ? $this->factory->createEncodingParameters() : $parameters, $container);
 }