You are here

bootstrap_site_alert.install in Bootstrap Site Alert 8

Same filename and directory in other branches
  1. 8.2 bootstrap_site_alert.install
  2. 7 bootstrap_site_alert.install

The bootstrap_site_alert install file.

File

bootstrap_site_alert.install
View source
<?php

/**
 * @file
 * The bootstrap_site_alert install file.
 */
use Drupal\user\RoleInterface;

/**
 * Implements hook_install().
 */
function bootstrap_site_alert_install() {

  // Add default permissions for viewing.
  user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, [
    'view bootstrap site alerts',
  ]);
  user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, [
    'view bootstrap site alerts',
  ]);
}

/**
 * Implements hook_uninstall().
 */
function bootstrap_site_alert_uninstall() {

  // Remove state that the module has set.
  $string = 'bootstrap_site_alert';
  $database = \Drupal::database();
  $database
    ->delete('key_value')
    ->condition('name', $database
    ->escapeLike($string) . "%", 'LIKE')
    ->execute();

  // Remove settings. We switched to states in 8.x-1.3. Leaving this is for
  // older versions of the module.
  \Drupal::service('config.factory')
    ->getEditable('bootstrap_site_alert.settings')
    ->delete();
}

/**
 * Add in Default Permissions for Viewing the Site Alert.
 */
function bootstrap_site_alert_update_8101() {
  user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, [
    'view bootstrap site alerts',
  ]);
  user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, [
    'view bootstrap site alerts',
  ]);
}

/**
 * Remove all config since we are now using states in the forms.
 */
function bootstrap_site_alert_update_8102() {
  \Drupal::service('config.factory')
    ->getEditable('bootstrap_site_alert.settings')
    ->delete();
}

Functions

Namesort descending Description
bootstrap_site_alert_install Implements hook_install().
bootstrap_site_alert_uninstall Implements hook_uninstall().
bootstrap_site_alert_update_8101 Add in Default Permissions for Viewing the Site Alert.
bootstrap_site_alert_update_8102 Remove all config since we are now using states in the forms.