You are here

class NullFieldNormalizerValue in JSON:API 8

Normalizes null fields in accordance with the JSON API specification.

@internal

Hierarchy

Expanded class hierarchy of NullFieldNormalizerValue

3 files declare their use of NullFieldNormalizerValue
EntityNormalizer.php in src/Normalizer/EntityNormalizer.php
EntityReferenceFieldNormalizer.php in src/Normalizer/EntityReferenceFieldNormalizer.php
FieldNormalizer.php in src/Normalizer/FieldNormalizer.php

File

src/Normalizer/Value/NullFieldNormalizerValue.php, line 13

Namespace

Drupal\jsonapi\Normalizer\Value
View source
class NullFieldNormalizerValue implements FieldNormalizerValueInterface {
  use CacheableDependencyTrait;

  /**
   * The property type.
   *
   * @var mixed
   */
  protected $propertyType;

  /**
   * Instantiate a FieldNormalizerValue object.
   *
   * @param \Drupal\Core\Access\AccessResultInterface $field_access_result
   *   The field access result.
   * @param string $property_type
   *   The property type of the field: 'attributes' or 'relationships'.
   */
  public function __construct(AccessResultInterface $field_access_result, $property_type) {
    assert($property_type === 'attributes' || $property_type === 'relationships');
    $this
      ->setCacheability($field_access_result);
    $this->propertyType = $property_type;
  }

  /**
   * {@inheritdoc}
   */
  public function getIncludes() {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function getPropertyType() {
    return $this->propertyType;
  }

  /**
   * {@inheritdoc}
   */
  public function rasterizeValue() {
    return NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function rasterizeIncludes() {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function getAllIncludes() {
    return NULL;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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.
NullFieldNormalizerValue::$propertyType protected property The property type.
NullFieldNormalizerValue::getAllIncludes public function Computes all the nested includes recursively. Overrides FieldNormalizerValueInterface::getAllIncludes
NullFieldNormalizerValue::getIncludes public function Gets the includes. Overrides FieldNormalizerValueInterface::getIncludes
NullFieldNormalizerValue::getPropertyType public function Gets the propertyType. Overrides FieldNormalizerValueInterface::getPropertyType
NullFieldNormalizerValue::rasterizeIncludes public function Get the includes. Overrides ValueExtractorInterface::rasterizeIncludes
NullFieldNormalizerValue::rasterizeValue public function Get the rasterized value. Overrides ValueExtractorInterface::rasterizeValue
NullFieldNormalizerValue::__construct public function Instantiate a FieldNormalizerValue object.