You are here

final class EdgeConfigTranslationChangeSubscriber in Apigee Edge 8

Clears caches when an Apigee Edge related config translation gets updated.

The primary purpose of this subscriber is to clear all caches when Apigee Edge custom entity labels gets translated via config objects.

Hierarchy

Expanded class hierarchy of EdgeConfigTranslationChangeSubscriber

1 string reference to 'EdgeConfigTranslationChangeSubscriber'
apigee_edge.services.yml in ./apigee_edge.services.yml
apigee_edge.services.yml
1 service uses EdgeConfigTranslationChangeSubscriber
apigee_edge.event_subscriber.edge_config_translation_change_subscriber in ./apigee_edge.services.yml
Drupal\apigee_edge\EventSubscriber\EdgeConfigTranslationChangeSubscriber

File

src/EventSubscriber/EdgeConfigTranslationChangeSubscriber.php, line 33

Namespace

Drupal\apigee_edge\EventSubscriber
View source
final class EdgeConfigTranslationChangeSubscriber implements EventSubscriberInterface {

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    if (class_exists('\\Drupal\\language\\Config\\LanguageConfigOverrideEvents')) {
      return [
        LanguageConfigOverrideEvents::SAVE_OVERRIDE => 'clearCache',
        LanguageConfigOverrideEvents::DELETE_OVERRIDE => 'clearCache',
      ];
    }
    return [];
  }

  /**
   * Clears caches when an Edge entity type's config translation gets updated.
   *
   * @param \Drupal\language\Config\LanguageConfigOverrideCrudEvent $event
   *   The event object.
   */
  public function clearCache(LanguageConfigOverrideCrudEvent $event) {

    /** @var \Drupal\language\Config\LanguageConfigOverride $override */
    $override = $event
      ->getLanguageConfigOverride();
    if (preg_match('/^apigee_edge/', $override
      ->getName())) {

      // It is easier to do that rather than just trying to figure our all
      // cache bins and tags that requires invalidation. We tried that.
      drupal_flush_all_caches();
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EdgeConfigTranslationChangeSubscriber::clearCache public function Clears caches when an Edge entity type's config translation gets updated.
EdgeConfigTranslationChangeSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.