smsplatform-1.0.x-dev/modules/smsplatform_user/smsplatform_user.module

modules/smsplatform_user/smsplatform_user.module
<?php

/**
 * @file
 * Provides integration between the SMS Platform and Drupal users.
 */

declare(strict_types=1);

use Drupal\Core\Entity\EntityInterface;
use Drupal\smsplatform\Entity\PhoneNumberSettingsInterface;
use Drupal\smsplatform\Entity\SmsMessageInterface as SmsMessageEntityInterface;

/**
 * Implements hook_entity_presave().
 */
function smsplatform_user_entity_presave(EntityInterface $entity): void {
  // Delay sending SMS message if active hours are enabled.
  if ($entity instanceof SmsMessageEntityInterface) {
    /** @var \Drupal\smsplatform_user\ActiveHoursInterface $active_hours */
    $active_hours = \Drupal::service('smsplatform_user.active_hours');
    $active_hours->delaySmsMessage($entity);
  }
}

/**
 * Implements hook_entity_insert().
 */
function smsplatform_user_entity_insert(EntityInterface $entity): void {
  // 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();
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc