You are here

class ConfigEventsSubscriber in TMGMT Translator Smartling 8.4

Same name and namespace in other branches
  1. 8.3 src/EventSubscriber/ConfigEventsSubscriber.php \Drupal\tmgmt_smartling\EventSubscriber\ConfigEventsSubscriber

Class ConfigEventsSubscriber.

@package Drupal\tmgmt_smartling\EventSubscriber

Hierarchy

  • class \Drupal\tmgmt_smartling\EventSubscriber\ConfigEventsSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of ConfigEventsSubscriber

1 string reference to 'ConfigEventsSubscriber'
tmgmt_smartling.services.yml in ./tmgmt_smartling.services.yml
tmgmt_smartling.services.yml
1 service uses ConfigEventsSubscriber
tmgmt_smartling.event_subscriber.config in ./tmgmt_smartling.services.yml
\Drupal\tmgmt_smartling\EventSubscriber\ConfigEventsSubscriber

File

src/EventSubscriber/ConfigEventsSubscriber.php, line 15

Namespace

Drupal\tmgmt_smartling\EventSubscriber
View source
class ConfigEventsSubscriber implements EventSubscriberInterface {

  /**
   * @var CacheTagsInvalidator
   */
  private $cacheInvalidator;

  /**
   * ConfigEventsSubscriber constructor.
   *
   * @param \Drupal\Core\Cache\CacheTagsInvalidator $cacheInvalidator
   */
  public function __construct(CacheTagsInvalidator $cacheInvalidator) {
    $this->cacheInvalidator = $cacheInvalidator;
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[ConfigEvents::SAVE][] = [
      'onSavingConfig',
    ];
    return $events;
  }

  /**
   * Subscriber Callback for the event.
   * @param ConfigCrudEvent $event
   */
  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"]}",
      ]);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigEventsSubscriber::$cacheInvalidator private property
ConfigEventsSubscriber::getSubscribedEvents public static function
ConfigEventsSubscriber::onSavingConfig public function Subscriber Callback for the event.
ConfigEventsSubscriber::__construct public function ConfigEventsSubscriber constructor.