sms_user.module in SMS Framework 2.x
Provides integration between the SMS Framework and Drupal users.
File
modules/sms_user/sms_user.moduleView source
<?php
declare (strict_types=1);
/**
* @file
* Provides integration between the SMS Framework and Drupal users.
*/
use Drupal\Core\Entity\EntityInterface;
use Drupal\sms\Entity\SmsMessageInterface as SmsMessageEntityInterface;
use Drupal\sms\Entity\PhoneNumberSettingsInterface;
/**
* Implements hook_entity_presave().
*/
function sms_user_entity_presave(EntityInterface $entity) {
// Delay sending SMS message if active hours are enabled.
if ($entity instanceof SmsMessageEntityInterface) {
/** @var \Drupal\sms_user\ActiveHoursInterface $active_hours */
$active_hours = \Drupal::service('sms_user.active_hours');
$active_hours
->delaySmsMessage($entity);
}
}
/**
* Implements hook_entity_insert().
*/
function sms_user_entity_insert(EntityInterface $entity) {
// Rebuild dynamic menu links if phone number settings for 'user' added.
if ($entity instanceof PhoneNumberSettingsInterface && $entity
->getPhoneNumberEntityTypeId() == 'user') {
/** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link */
$menu_link = \Drupal::service('plugin.manager.menu.link');
$menu_link
->rebuild();
}
}
Functions
Name | Description |
---|---|
sms_user_entity_insert | Implements hook_entity_insert(). |
sms_user_entity_presave | Implements hook_entity_presave(). |