class BynderConfigHashGenerator in Bynder 8.2
Same name and namespace in other branches
- 8.3 src/EventSubscriber/BynderConfigHashGenerator.php \Drupal\bynder\EventSubscriber\BynderConfigHashGenerator
- 8 src/EventSubscriber/BynderConfigHashGenerator.php \Drupal\bynder\EventSubscriber\BynderConfigHashGenerator
- 4.0.x src/EventSubscriber/BynderConfigHashGenerator.php \Drupal\bynder\EventSubscriber\BynderConfigHashGenerator
A subscriber that generates Bynder config hash.
Hash is used to validate active user sessions.
Hierarchy
- class \Drupal\bynder\EventSubscriber\BynderConfigHashGenerator implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of BynderConfigHashGenerator
1 string reference to 'BynderConfigHashGenerator'
1 service uses BynderConfigHashGenerator
File
- src/
EventSubscriber/ BynderConfigHashGenerator.php, line 15
Namespace
Drupal\bynder\EventSubscriberView source
class BynderConfigHashGenerator implements EventSubscriberInterface {
/**
* The state service.
*
* @var \Drupal\Core\State\StateInterface
*/
protected $state;
/**
* Constructs a BynderConfigHashGenerator object.
*
* @param \Drupal\Core\State\StateInterface $state
* The state service.
*/
public function __construct(StateInterface $state) {
$this->state = $state;
}
/**
* Generates hash based on active Bynder config and saves it into state.
*
* @param \Drupal\Core\Config\ConfigCrudEvent $event
* The Event to process.
*/
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)));
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[ConfigEvents::SAVE][] = [
'onChange',
];
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BynderConfigHashGenerator:: |
protected | property | The state service. | |
BynderConfigHashGenerator:: |
public static | function | ||
BynderConfigHashGenerator:: |
public | function | Generates hash based on active Bynder config and saves it into state. | |
BynderConfigHashGenerator:: |
public | function | Constructs a BynderConfigHashGenerator object. |