You are here

class IncludeOnlyRelationshipNormalizerValue in JSON:API 8

Helps normalize relationships in compliance with the JSON API spec.

Specifically designed for include-only relationships: when a relationship field is omitted due to a sparse fieldset, yet its related resources are included via `?include`.

@internal

Hierarchy

Expanded class hierarchy of IncludeOnlyRelationshipNormalizerValue

1 file declares its use of IncludeOnlyRelationshipNormalizerValue
EntityNormalizer.php in src/Normalizer/EntityNormalizer.php

File

src/Normalizer/Value/IncludeOnlyRelationshipNormalizerValue.php, line 16

Namespace

Drupal\jsonapi\Normalizer\Value
View source
class IncludeOnlyRelationshipNormalizerValue extends FieldNormalizerValue {

  /**
   * Instantiate a IncludeOnlyRelationshipNormalizerValue object.
   *
   * @param \Drupal\jsonapi\Normalizer\Value\RelationshipNormalizerValue $relationship_normalizer_value
   *   The relationship normalizer value to convert into an include-only one.
   */
  public function __construct(RelationshipNormalizerValue $relationship_normalizer_value) {
    assert(!empty($relationship_normalizer_value
      ->getIncludes()), sprintf('%s should only be used for relationships that do have includes.', get_called_class()));
    parent::__construct(AccessResult::allowed(), [], NULL, 'relationships');
    $this->includes = $relationship_normalizer_value
      ->getIncludes();
    $this
      ->setCacheability($relationship_normalizer_value);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableDependenciesMergerTrait::mergeCacheableDependencies protected static function Determines the joint cacheability of all provided dependencies.
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::getCacheContexts public function
CacheableDependencyTrait::getCacheMaxAge public function
CacheableDependencyTrait::getCacheTags public function
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
FieldNormalizerValue::$cardinality protected property The field cardinality.
FieldNormalizerValue::$includes protected property The includes.
FieldNormalizerValue::$propertyType protected property The property type. Either: 'attributes' or `relationships'.
FieldNormalizerValue::$values protected property The values.
FieldNormalizerValue::getAllIncludes public function Computes all the nested includes recursively. Overrides FieldNormalizerValueInterface::getAllIncludes
FieldNormalizerValue::getIncludes public function Gets the includes. Overrides FieldNormalizerValueInterface::getIncludes
FieldNormalizerValue::getPropertyType public function Gets the propertyType. Overrides FieldNormalizerValueInterface::getPropertyType
FieldNormalizerValue::rasterizeIncludes public function Get the includes. Overrides ValueExtractorInterface::rasterizeIncludes
FieldNormalizerValue::rasterizeValue public function Get the rasterized value. Overrides ValueExtractorInterface::rasterizeValue 1
IncludeOnlyRelationshipNormalizerValue::__construct public function Instantiate a IncludeOnlyRelationshipNormalizerValue object. Overrides FieldNormalizerValue::__construct