class CaptchaCachedSettingsSubscriber in CAPTCHA 8
A subscriber clearing the cached definitions when saving captcha settings.
Hierarchy
- class \Drupal\captcha\EventSubscriber\CaptchaCachedSettingsSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of CaptchaCachedSettingsSubscriber
1 string reference to 'CaptchaCachedSettingsSubscriber'
1 service uses CaptchaCachedSettingsSubscriber
File
- src/EventSubscriber/ CaptchaCachedSettingsSubscriber.php, line 13 
Namespace
Drupal\captcha\EventSubscriberView source
class CaptchaCachedSettingsSubscriber implements EventSubscriberInterface {
  /**
   * The Element info.
   *
   * @var \Drupal\Core\Render\ElementInfoManagerInterface
   */
  protected $elementInfo;
  /**
   * CaptchaCachedSettingsSubscriber constructor.
   *
   * @param \Drupal\Core\Render\ElementInfoManagerInterface $elementInfo
   *   Constructor.
   */
  public function __construct(ElementInfoManagerInterface $elementInfo) {
    $this->elementInfo = $elementInfo;
  }
  /**
   * Clearing the cached definitions whenever the settings are modified.
   *
   * @param \Drupal\Core\Config\ConfigCrudEvent $event
   *   The Event to process.
   */
  public function onSave(ConfigCrudEvent $event) {
    // Changing the Captcha settings means that any page might result in other
    // settings for captcha so the cached definitions need to be cleared.
    if ($event
      ->getConfig()
      ->getName() === 'captcha.settings') {
      $this->elementInfo
        ->clearCachedDefinitions();
    }
  }
  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[ConfigEvents::SAVE][] = [
      'onSave',
    ];
    return $events;
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| CaptchaCachedSettingsSubscriber:: | protected | property | The Element info. | |
| CaptchaCachedSettingsSubscriber:: | public static | function | Returns an array of event names this subscriber wants to listen to. | |
| CaptchaCachedSettingsSubscriber:: | public | function | Clearing the cached definitions whenever the settings are modified. | |
| CaptchaCachedSettingsSubscriber:: | public | function | CaptchaCachedSettingsSubscriber constructor. | 
