You are here

opigno_calendar_event.install in Opigno calendar event 8

Same filename and directory in other branches
  1. 3.x opigno_calendar_event.install

Install, update and uninstall functions for the Opigno Calendar Event module.

File

opigno_calendar_event.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the Opigno Calendar Event module.
 */
use Drupal\opigno_calendar_event\CalendarEventAccess;
use Drupal\user\Entity\Role;
use Drupal\user\RoleInterface;

/**
 * Implements hook_install().
 */
function opigno_calendar_event_install() {
  opigno_calendar_event_set_permissions();
}

/**
 * Update access handler for opigno calendar event entity.
 */
function opigno_calendar_event_update_8001() {
  $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  $entity_type = $definition_update_manager
    ->getEntityType('opigno_calendar_event');
  $entity_type
    ->setHandlerClass('access', CalendarEventAccess::class);
  $definition_update_manager
    ->updateEntityType($entity_type);
}

/**
 * Setup calendar events permissions.
 */
function opigno_calendar_event_update_8002() {
  opigno_calendar_event_set_permissions();
}

/**
 * Sets roles opigno calendar event permissions.
 */
function opigno_calendar_event_set_permissions() {
  $role = Role::load(RoleInterface::AUTHENTICATED_ID);
  $role
    ->grantPermission('create opigno_calendar_event');
  $role
    ->grantPermission('view own opigno calendar event');
  $role
    ->grantPermission('update own opigno calendar event');
  $role
    ->grantPermission('delete own opigno calendar event');
  $role
    ->grantPermission('add members to calendar event');
  $role
    ->save();
  $role = Role::load('content_manager');
  $role
    ->grantPermission('view opigno_calendar_event');
  $role
    ->grantPermission('update opigno_calendar_event');
  $role
    ->grantPermission('delete opigno_calendar_event');
  $role
    ->grantPermission('add any members to calendar event');
  $role
    ->save();
  $role = Role::load('user_manager');
  $role
    ->grantPermission('view opigno_calendar_event');
  $role
    ->grantPermission('update opigno_calendar_event');
  $role
    ->grantPermission('delete opigno_calendar_event');
  $role
    ->grantPermission('add any members to calendar event');
  $role
    ->save();
}

Functions

Namesort descending Description
opigno_calendar_event_install Implements hook_install().
opigno_calendar_event_set_permissions Sets roles opigno calendar event permissions.
opigno_calendar_event_update_8001 Update access handler for opigno calendar event entity.
opigno_calendar_event_update_8002 Setup calendar events permissions.