You are here

public function BynderConfigHashGenerator::onChange in Bynder 8.3

Same name and namespace in other branches
  1. 8 src/EventSubscriber/BynderConfigHashGenerator.php \Drupal\bynder\EventSubscriber\BynderConfigHashGenerator::onChange()
  2. 8.2 src/EventSubscriber/BynderConfigHashGenerator.php \Drupal\bynder\EventSubscriber\BynderConfigHashGenerator::onChange()
  3. 4.0.x src/EventSubscriber/BynderConfigHashGenerator.php \Drupal\bynder\EventSubscriber\BynderConfigHashGenerator::onChange()

Generates hash based on active Bynder config and saves it into state.

Parameters

\Drupal\Core\Config\ConfigCrudEvent $event: The Event to process.

File

src/EventSubscriber/BynderConfigHashGenerator.php, line 40

Class

BynderConfigHashGenerator
A subscriber that generates Bynder config hash.

Namespace

Drupal\bynder\EventSubscriber

Code

public function onChange(ConfigCrudEvent $event) {
  if (strpos($event
    ->getConfig()
    ->getName(), 'bynder.settings') === 0) {
    $hash_source = [];
    foreach ([
      'consumer_key',
      'consumer_secret',
      'token',
      'token_secret',
      'account_domain',
    ] as $key) {
      $hash_source[] = $event
        ->getConfig()
        ->get($key);
    }
    $this->state
      ->set('bynder_config_hash', md5(implode(':', $hash_source)));
  }
}