You are here

popup_message.install in Popup message 8

Same filename and directory in other branches
  1. 6 popup_message.install
  2. 7 popup_message.install

Install, update and uninstall functions for the Popup message module.

File

popup_message.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the Popup message module.
 */
use Drupal\user\RoleInterface;

/**
 * Implements hook_uninstall().
 */
function popup_message_install() {
  \Drupal::messenger()
    ->addMessage(t('Popup message: Go to "Configuration -> User interface -> Popup message" and set popup message title and body'));

  // Set default settings - permission, hidden on admin pages.
  user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, [
    'display popup message',
  ]);
  user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, [
    'display popup message',
  ]);
  $config = Drupal::configFactory()
    ->getEditable('popup_message.settings');
  $config
    ->set('visibility_pages', 'admin/*')
    ->save();
}

/**
 * Implements hook_uninstall().
 */
function popup_message_uninstall() {
  Drupal::configFactory()
    ->getEditable('popup_message.settings')
    ->delete();
}

Functions