user_event_dispatcher.module in Hook Event Dispatcher 3.x
Same filename and directory in other branches
User event dispatcher submodule.
File
modules/user_event_dispatcher/user_event_dispatcher.moduleView source
<?php
/**
* @file
* User event dispatcher submodule.
*/
use Drupal\Core\Session\AccountInterface;
use Drupal\user_event_dispatcher\Event\User\UserCancelEvent;
use Drupal\user_event_dispatcher\Event\User\UserCancelMethodsAlterEvent;
use Drupal\user_event_dispatcher\Event\User\UserFormatNameAlterEvent;
use Drupal\user_event_dispatcher\Event\User\UserLoginEvent;
use Drupal\user_event_dispatcher\Event\User\UserLogoutEvent;
/**
* Implements hook_user_cancel().
*
* {@inheritdoc}
*/
function user_event_dispatcher_user_cancel(array $edit, AccountInterface $account, string $method) {
/** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = Drupal::service('hook_event_dispatcher.manager');
$event = new UserCancelEvent($edit, $account, $method);
$manager
->register($event);
}
/**
* Implements hook_user_cancel_methods_alter().
*
* {@inheritdoc}
*/
function user_event_dispatcher_user_cancel_methods_alter(array &$methods) {
/** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = Drupal::service('hook_event_dispatcher.manager');
$event = new UserCancelMethodsAlterEvent($methods);
$manager
->register($event);
}
/**
* Implements hook_user_login().
*
* {@inheritdoc}
*/
function user_event_dispatcher_user_login(AccountInterface $account) {
/** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = Drupal::service('hook_event_dispatcher.manager');
$event = new UserLoginEvent($account);
$manager
->register($event);
}
/**
* Implements hook_user_logout().
*
* {@inheritdoc}
*/
function user_event_dispatcher_user_logout(AccountInterface $account) {
/** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = Drupal::service('hook_event_dispatcher.manager');
$event = new UserLogoutEvent($account);
$manager
->register($event);
}
/**
* Implements hook_user_format_name_alter().
*
* {@inheritdoc}
*/
function user_event_dispatcher_user_format_name_alter(&$name, AccountInterface $account) {
/** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = Drupal::service('hook_event_dispatcher.manager');
$event = new UserFormatNameAlterEvent($name, $account);
$manager
->register($event);
}
Functions
Name | Description |
---|---|
user_event_dispatcher_user_cancel | Implements hook_user_cancel(). |
user_event_dispatcher_user_cancel_methods_alter | Implements hook_user_cancel_methods_alter(). |
user_event_dispatcher_user_format_name_alter | Implements hook_user_format_name_alter(). |
user_event_dispatcher_user_login | Implements hook_user_login(). |
user_event_dispatcher_user_logout | Implements hook_user_logout(). |