You are here

class TawkToCacheManager in Tawk.to - Live chat application (Drupal 8) 8.2

Same name and namespace in other branches
  1. 8 src/Cache/TawkToCacheManager.php \Drupal\tawk_to\Cache\TawkToCacheManager

Defines the cache manager tawk.to service.

Hierarchy

Expanded class hierarchy of TawkToCacheManager

1 file declares its use of TawkToCacheManager
TawkToEmbedRender.php in src/Service/TawkToEmbedRender.php
1 string reference to 'TawkToCacheManager'
tawk_to.services.yml in ./tawk_to.services.yml
tawk_to.services.yml
1 service uses TawkToCacheManager
tawk_to.cache_manager in ./tawk_to.services.yml
Drupal\tawk_to\Cache\TawkToCacheManager

File

src/Cache/TawkToCacheManager.php, line 11

Namespace

Drupal\tawk_to\Cache
View source
class TawkToCacheManager {

  /**
   * The condition plugin defination.
   *
   * @var \Drupal\tawk_to\Service\TawkToConditionPluginsHandler
   */
  protected $conditionsPluginsHandler;

  /**
   * Constructs the TawkToCacheManager.
   *
   * @param Drupal\tawk_to\Service\TawkToConditionPluginsHandler $conditionsPluginsHandler
   *   The tawk.to access controller handler.
   */
  public function __construct(TawkToConditionPluginsHandler $conditionsPluginsHandler) {
    $this->conditionsPluginsHandler = $conditionsPluginsHandler;
  }

  /**
   * Gets cache tags based on the module settings and context plugins tags.
   *
   * @return array
   *   The cache tags.
   */
  public function getCacheTags() {
    $tags = [
      'config:tawk_to.settings',
    ];
    $conditions = $this->conditionsPluginsHandler
      ->getConditions();
    foreach ($conditions as $condition) {
      if ($condition instanceof CacheableDependencyInterface) {
        $tags = array_merge($tags, $condition
          ->getCacheTags());
      }
    }
    return $tags;
  }

  /**
   * Gets cache tags based on the module settings and context plugins tags.
   *
   * @return array
   *   The cache tags.
   */
  public function getCacheContexts() {
    $contexts = [
      'session',
    ];
    $conditions = $this->conditionsPluginsHandler
      ->getConditions();
    foreach ($conditions as $condition) {
      if ($condition instanceof CacheableDependencyInterface) {
        $contexts = array_merge($contexts, $condition
          ->getCacheContexts());
      }
    }
    return $contexts;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TawkToCacheManager::$conditionsPluginsHandler protected property The condition plugin defination.
TawkToCacheManager::getCacheContexts public function Gets cache tags based on the module settings and context plugins tags.
TawkToCacheManager::getCacheTags public function Gets cache tags based on the module settings and context plugins tags.
TawkToCacheManager::__construct public function Constructs the TawkToCacheManager.