You are here

opigno_dashboard.install in Opigno dashboard 3.x

Same filename and directory in other branches
  1. 8 opigno_dashboard.install

Install, update and uninstall functions for the alt_aero_log_contacts module.

File

opigno_dashboard.install
View source
<?php

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

/**
 * Implements hook_schema().
 */
function opigno_dashboard_schema() {
  $schema['opigno_dashboard_positioning'] = [
    'fields' => [
      'pid' => [
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'uid' => [
        'type' => 'int',
        'not null' => TRUE,
      ],
      'columns' => [
        'type' => 'int',
        'not null' => TRUE,
      ],
      'positions' => [
        'type' => 'text',
        'not null' => TRUE,
      ],
    ],
    'primary key' => [
      'pid',
    ],
  ];
  return $schema;
}

/**
 * Implements hook_install().
 */
function opigno_dashboard_install() {
  $blocks = \Drupal::config('opigno_dashboard.settings')
    ->get('blocks');

  // Create block instances.
  \Drupal::service('opigno_dashboard.block')
    ->createBlocksInstances($blocks);

  // Grant 'opigno dashboard layout access' permission.
  $roles = Role::loadMultiple();
  foreach ($roles as $role) {
    $role
      ->grantPermission('opigno dashboard layout access');
    try {
      $role
        ->save();
    } catch (EntityStorageException $e) {
      watchdog_exception('opigno_dashboard_exception', $e);
    }
  }
}

Functions