You are here

ShsTermCacheDependency.php in Simple hierarchical select 2.0.x

Same filename and directory in other branches
  1. 8 src/Cache/ShsTermCacheDependency.php

Namespace

Drupal\shs\Cache

File

src/Cache/ShsTermCacheDependency.php
View source
<?php

namespace Drupal\shs\Cache;

use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableDependencyInterface;

/**
 * Cacheable dependency object for term data.
 */
class ShsTermCacheDependency implements CacheableDependencyInterface {

  /**
   * {@inheritdoc}
   */
  public function __construct($tags = []) {
    $this->contexts = [
      'languages:language_interface',
    ];
    $this->tags = Cache::mergeTags([
      'taxonomy_term_values',
    ], $tags);
    $this->maxAge = Cache::PERMANENT;
  }

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

  /**
   * {@inheritdoc}
   */
  public function getCacheTags() {
    return Cache::mergeTags($this->tags, \Drupal::entityTypeManager()
      ->getDefinition('taxonomy_term')
      ->getListCacheTags());
  }

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

}

Classes

Namesort descending Description
ShsTermCacheDependency Cacheable dependency object for term data.