You are here

trait CacheableDependenciesMergerTrait in JSON:API 8

Trait for \Drupal\Core\Cache\CacheableDependencyInterface::setCacheability().

@internal

Hierarchy

File

src/Normalizer/Value/CacheableDependenciesMergerTrait.php, line 12

Namespace

Drupal\jsonapi\Normalizer\Value
View source
trait CacheableDependenciesMergerTrait {

  /**
   * Determines the joint cacheability of all provided dependencies.
   *
   * @param \Drupal\Core\Cache\CacheableDependencyInterface|object[] $dependencies
   *   The dependencies.
   *
   * @return \Drupal\Core\Cache\CacheableMetadata
   *   The cacheability of all dependencies.
   *
   * @see \Drupal\Core\Cache\RefinableCacheableDependencyInterface::addCacheableDependency()
   */
  protected static function mergeCacheableDependencies(array $dependencies) {
    $merged_cacheability = new CacheableMetadata();
    array_walk($dependencies, function ($dependency) use ($merged_cacheability) {
      $merged_cacheability
        ->addCacheableDependency($dependency);
    });
    return $merged_cacheability;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableDependenciesMergerTrait::mergeCacheableDependencies protected static function Determines the joint cacheability of all provided dependencies.