You are here

class ImageNormalizerValue in Consumer Image Styles 8.2

Same name and namespace in other branches
  1. 8 src/Normalizer/Value/ImageNormalizerValue.php \Drupal\consumer_image_styles\Normalizer\Value\ImageNormalizerValue

Hierarchy

Expanded class hierarchy of ImageNormalizerValue

1 file declares its use of ImageNormalizerValue
ImageEntityNormalizer.php in src/Normalizer/ImageEntityNormalizer.php

File

src/Normalizer/Value/ImageNormalizerValue.php, line 10

Namespace

Drupal\consumer_image_styles\Normalizer\Value
View source
class ImageNormalizerValue implements ValueExtractorInterface, RefinableCacheableDependencyInterface {
  use RefinableCacheableDependencyTrait;

  /**
   * @var \Drupal\jsonapi\Normalizer\Value\EntityNormalizerValue
   */
  protected $subject;

  /**
   * The values.
   *
   * @param array
   */
  protected $variants;

  /**
   * ImageNormalizerValue constructor.
   */
  public function __construct($variants, EntityNormalizerValue $subject) {
    $this->subject = $subject;
    $this->variants = $variants;
    $this
      ->addCacheableDependency($variants);
  }

  /**
   * {@inheritdoc}
   */
  public function rasterizeValue() {
    $rasterized = $this->subject
      ->rasterizeValue();
    $derivatives = $this->variants
      ->rasterizeValue();
    if (empty($derivatives)) {
      return $rasterized;
    }
    $rasterized['meta'] = empty($rasterized['meta']) ? [] : $rasterized['meta'];
    $rasterized['meta']['derivatives'] = $derivatives;
    return $rasterized;
  }

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

  /**
   * Gets the values.
   *
   * @return mixed
   *   The values.
   */
  public function getValues() {
    return $this->subject
      ->getValues();
  }

  /**
   * Gets a flattened list of includes in all the chain.
   *
   * @return \Drupal\jsonapi\Normalizer\Value\EntityNormalizerValue[]
   *   The array of included relationships.
   */
  public function getIncludes() {
    return $this->subject
      ->getIncludes();
  }

}

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 3
CacheableDependencyTrait::getCacheMaxAge public function 3
CacheableDependencyTrait::getCacheTags public function 3
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
ImageNormalizerValue::$subject protected property
ImageNormalizerValue::$variants protected property The values.
ImageNormalizerValue::getIncludes public function Gets a flattened list of includes in all the chain.
ImageNormalizerValue::getValues public function Gets the values.
ImageNormalizerValue::rasterizeIncludes public function Get the includes. Overrides ValueExtractorInterface::rasterizeIncludes
ImageNormalizerValue::rasterizeValue public function Get the rasterized value. Overrides ValueExtractorInterface::rasterizeValue
ImageNormalizerValue::__construct public function ImageNormalizerValue constructor.
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function