You are here

public function LinkCollectionNormalizer::normalize in Consumer Image Styles 4.x

Same name and namespace in other branches
  1. 8.3 src/Normalizer/LinkCollectionNormalizer.php \Drupal\consumer_image_styles\Normalizer\LinkCollectionNormalizer::normalize()

File

src/Normalizer/LinkCollectionNormalizer.php, line 85

Class

LinkCollectionNormalizer
Custom normalizer that add the derivatives to image entities.

Namespace

Drupal\consumer_image_styles\Normalizer

Code

public function normalize($link_collection, $format = NULL, array $context = []) {
  assert($link_collection instanceof LinkCollection);
  if ($this
    ->decorationApplies($link_collection) && ($consumer = $this
    ->getConsumer())) {
    $variant_links = $this
      ->buildVariantLinks($link_collection
      ->getContext(), $consumer);
    $normalization = $this->inner
      ->normalize(LinkCollection::merge($link_collection, $variant_links), $format, $context);
    return static::addLinkRels($normalization, $variant_links)
      ->withCacheableDependency($consumer);
  }
  return $this->inner
    ->normalize($link_collection, $format, $context);
}