TawkToCacheManager.php in Tawk.to - Live chat application (Drupal 8) 8.2
File
src/Cache/TawkToCacheManager.php
View source
<?php
namespace Drupal\tawk_to\Cache;
use Drupal\tawk_to\Service\TawkToConditionPluginsHandler;
use Drupal\Core\Cache\CacheableDependencyInterface;
class TawkToCacheManager {
protected $conditionsPluginsHandler;
public function __construct(TawkToConditionPluginsHandler $conditionsPluginsHandler) {
$this->conditionsPluginsHandler = $conditionsPluginsHandler;
}
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;
}
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;
}
}