You are here

subscriptions.module in Subscriptions 2.0.x

Module file for the basic Subscriptions framework.

File

subscriptions.module
View source
<?php

/**
 * @file
 * Module file for the basic Subscriptions framework.
 */
use Drupal\user\UserInterface;

/**
 * Implements hook_ENTITY_TYPE_insert().
 */
function subscriptions_user_insert(UserInterface $user) {
  \Drupal::database()
    ->insert('subscriptions')
    ->fields([
    'uid',
  ], [
    $user
      ->id(),
  ])
    ->execute();
}

/**
 * Implements hook_ENTITY_TYPE_update().
 */
function subscriptions_user_update(UserInterface $user) {
  if ($user
    ->isBlocked() && !$user->original
    ->isBlocked()) {

    // @todo Fill out this stub.
  }
}

/**
 * Implements hook_ENTITY_TYPE_delete().
 */
function subscriptions_user_delete(UserInterface $user) {
  \Drupal::database()
    ->delete('subscriptions_user')
    ->condition('uid', $user
    ->id())
    ->execute();
  \Drupal::database()
    ->delete('subscriptions_last_sent')
    ->condition('uid', $user
    ->id())
    ->execute();
}

/**
 * Implements hook_user_cancel().
 */
function subscriptions_user_cancel($edit, UserInterface $account, $method) {
  subscriptions_user_delete($account);
}