class LocaleTranslationCacheTag
Same name in other branches
- 9 core/modules/locale/src/EventSubscriber/LocaleTranslationCacheTag.php \Drupal\locale\EventSubscriber\LocaleTranslationCacheTag
- 10 core/modules/locale/src/EventSubscriber/LocaleTranslationCacheTag.php \Drupal\locale\EventSubscriber\LocaleTranslationCacheTag
- 11.x core/modules/locale/src/EventSubscriber/LocaleTranslationCacheTag.php \Drupal\locale\EventSubscriber\LocaleTranslationCacheTag
A subscriber invalidating cache tags when translating a string.
Hierarchy
- class \Drupal\locale\EventSubscriber\LocaleTranslationCacheTag implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of LocaleTranslationCacheTag
1 string reference to 'LocaleTranslationCacheTag'
- locale.services.yml in core/
modules/ locale/ locale.services.yml - core/modules/locale/locale.services.yml
1 service uses LocaleTranslationCacheTag
File
-
core/
modules/ locale/ src/ EventSubscriber/ LocaleTranslationCacheTag.php, line 12
Namespace
Drupal\locale\EventSubscriberView source
class LocaleTranslationCacheTag implements EventSubscriberInterface {
/**
* The cache tags invalidator.
*
* @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface
*/
protected $cacheTagsInvalidator;
/**
* Constructs a LocaleTranslationCacheTag object.
*
* @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_invalidator
* The cache tags invalidator.
*/
public function __construct(CacheTagsInvalidatorInterface $cache_tags_invalidator) {
$this->cacheTagsInvalidator = $cache_tags_invalidator;
}
/**
* Invalidate cache tags whenever a string is translated.
*/
public function saveTranslation() {
$this->cacheTagsInvalidator
->invalidateTags([
'rendered',
'locale',
'library_info',
]);
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[LocaleEvents::SAVE_TRANSLATION][] = [
'saveTranslation',
];
return $events;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
LocaleTranslationCacheTag::$cacheTagsInvalidator | protected | property | The cache tags invalidator. |
LocaleTranslationCacheTag::getSubscribedEvents | public static | function | |
LocaleTranslationCacheTag::saveTranslation | public | function | Invalidate cache tags whenever a string is translated. |
LocaleTranslationCacheTag::__construct | public | function | Constructs a LocaleTranslationCacheTag object. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.