ConfigEventsSubscriber.php in TMGMT Translator Smartling 8.3
File
src/EventSubscriber/ConfigEventsSubscriber.php
View source
<?php
namespace Drupal\tmgmt_smartling\EventSubscriber;
use Drupal\Core\Cache\CacheTagsInvalidator;
use Drupal\Core\Config\ConfigCrudEvent;
use Drupal\Core\Config\ConfigEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ConfigEventsSubscriber implements EventSubscriberInterface {
private $cacheInvalidator;
public function __construct(CacheTagsInvalidator $cacheInvalidator) {
$this->cacheInvalidator = $cacheInvalidator;
}
public static function getSubscribedEvents() {
$events[ConfigEvents::SAVE][] = [
'onSavingConfig',
];
return $events;
}
public function onSavingConfig(ConfigCrudEvent $event) {
$config_data = $event
->getConfig()
->get();
if (!empty($config_data["plugin"]) && $config_data["plugin"] == "smartling" && !empty($config_data["settings"]["project_id"])) {
$this->cacheInvalidator
->invalidateTags([
"tmgmt_smartling:firebase_config:{$config_data["settings"]["project_id"]}",
]);
}
}
}