You are here

social_event_managers.install in Open Social 8.8

Install, update and uninstall functions for the social_event_managers module.

File

modules/social_features/social_event/modules/social_event_managers/social_event_managers.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the social_event_managers module.
 */
use Drupal\user\Entity\Role;

/**
 * Implements hook_install().
 *
 * Perform actions related to the installation of social_event_managers.
 */
function social_event_managers_install() {

  // Fetch site manager role.
  $role = Role::load('sitemanager');

  // Set permission for site manager.
  if ($role instanceof Role) {

    // Set permission.
    $role
      ->grantPermission('set social event managers settings');
    $role
      ->trustData()
      ->save();
  }

  // Add enrollments permissions to CM and SM.
  $roles = [
    'sitemanager',
    'contentmanager',
  ];
  foreach ($roles as $rolename) {
    $role = Role::load($rolename);

    // Set permission for site manager.
    if ($role instanceof Role) {

      // Set permission.
      $role
        ->grantPermission('manage everything enrollments');
      $role
        ->trustData()
        ->save();
    }
  }
}

/**
 * Perform actions related to the installation of social_event_managers.
 */
function social_event_managers_update_8001() {
  social_event_managers_install();
}

/**
 * Add manage enrollments permission to SM and CM.
 */
function social_event_managers_update_8003() {
  $roles = [
    'sitemanager',
    'contentmanager',
  ];
  foreach ($roles as $rolename) {
    $role = Role::load($rolename);

    // Set permission for site manager.
    if ($role instanceof Role) {

      // Set permission.
      $role
        ->grantPermission('manage everything enrollments');
      $role
        ->trustData()
        ->save();
    }
  }
}

Functions

Namesort descending Description
social_event_managers_install Implements hook_install().
social_event_managers_update_8001 Perform actions related to the installation of social_event_managers.
social_event_managers_update_8003 Add manage enrollments permission to SM and CM.