function business_rules_user_logout in Business Rules 2.x
Same name and namespace in other branches
- 8 business_rules.module \business_rules_user_logout()
Implements hook_user_logout().
File
- ./
business_rules.module, line 384 - Business Rules module.
Code
function business_rules_user_logout($account) {
$entity = User::load($account
->id());
if (\Drupal::service('business_rules.processor')
->ruleExists('user_logout', $entity)) {
$reacts_on_definition = \Drupal::getContainer()
->get('plugin.manager.business_rules.reacts_on')
->getDefinition('user_logout');
if (method_exists($account, 'getAccount')) {
$account = $account
->getAccount();
}
$entity_type_id = $entity
->getEntityTypeId();
$event = new BusinessRulesEvent($entity, [
'entity_type_id' => $entity_type_id,
'bundle' => $entity
->bundle(),
'entity' => $entity,
'entity_unchanged' => NULL,
'reacts_on' => $reacts_on_definition,
'loop_control' => $entity
->getEntityTypeId() . $entity
->id(),
]);
/** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher */
$event_dispatcher = \Drupal::service('event_dispatcher');
$event_dispatcher
->dispatch($reacts_on_definition['eventName'], $event);
}
}