Exemplo n.º 1
0
 /**
  * @param StackReadOnlyInterface $stack
  *
  * @return bool[]
  */
 private function foundInPaths(StackReadOnlyInterface $stack)
 {
     if ($stack->count() < 2) {
         // top level, no resources ware started to parse yet
         $onTheWay = true;
         $parentIsTarget = false;
     } else {
         $onTheWay = $this->parameters->hasMatchWithIncludedPaths($stack->end()->getPath());
         $parentIsTarget = $this->parameters->isPathIncluded($stack->penult()->getPath());
     }
     return [$onTheWay, $parentIsTarget];
 }
Exemplo n.º 2
0
 /**
  * If relationship from 'parent' to 'current' resource passes field set filter.
  *
  * @param Frame $current
  * @param Frame $previous
  *
  * @return bool
  */
 private function isRelationshipInFieldSet(Frame $current, Frame $previous)
 {
     if (($fieldSet = $this->parameters->getFieldSet($previous->getResource()->getType())) === null) {
         return true;
     }
     return in_array($current->getRelationship()->getName(), $fieldSet, true) === true;
 }
Exemplo n.º 3
0
 /**
  * @param string $type
  *
  * @return string[]
  */
 private function getIncludePathsByType($type)
 {
     // if include paths are set in params use them otherwise use default include paths from schema
     $includePaths = $this->parameters->getIncludePaths();
     if (empty($includePaths) === false) {
         $typePaths = $includePaths;
     } else {
         $schema = $this->container->getSchemaByResourceType($type);
         $typePaths = $schema->getIncludePaths();
     }
     return $typePaths;
 }
Exemplo n.º 4
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);
     }
 }
Exemplo n.º 5
0
 /**
  * @param array|object|null                $data
  * @param EncodingParametersInterface|null $parameters
  *
  * @return EncodingParametersInterface
  */
 private function getEncodingParameters($data, EncodingParametersInterface $parameters = null)
 {
     if (empty($data) === true && $parameters === null) {
         return $this->parametersFactory->createEncodingParameters();
     } elseif ($parameters !== null && $parameters->getIncludePaths() !== null) {
         return $parameters;
     } else {
         $schema = $this->container->getSchema(is_array($data) ? $data[0] : $data);
         $includePaths = $schema->getIncludePaths();
         $fieldSets = $parameters === null ? null : $parameters->getFieldSets();
         return $this->parametersFactory->createEncodingParameters($includePaths, $fieldSets);
     }
 }