You are here

lightning_layout.install in Lightning Layout 8.2

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

Contains installation and update routines for Lightning Layout.

File

lightning_layout.install
View source
<?php

/**
 * @file
 * Contains installation and update routines for Lightning Layout.
 */
use Drupal\lightning_core\ConfigHelper as Config;
use Drupal\user\Entity\Role;

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

  // React to other modules possibly being installed already.
  $modules = [
    'lightning_roles',
    'lightning_media',
  ];
  $modules = array_filter($modules, [
    Drupal::moduleHandler(),
    'moduleExists',
  ]);
  if ($modules) {
    lightning_layout_modules_installed($modules);
  }
}

/**
 * Installs default configuration for landing page content type.
 */
function lightning_layout_update_8001() {
  \Drupal::service('config.installer')
    ->installDefaultConfig('module', 'lightning_layout');
}

/**
 * Creates the layout_manager role.
 */
function lightning_layout_update_8002() {
  Config::forModule('lightning_layout')
    ->getEntity('user_role', 'layout_manager')
    ->save();
}

/**
 * Removed in Lightning 8.x-4.0.
 *
 * Formerly added layout permissions to layout_manager role.
 */
function lightning_layout_update_8003() {
}

/**
 * Removed in Lightning 8.x-2.05.
 *
 * Formerly installed Panelizer defaults for the landing_page content type.
 */
function lightning_layout_update_8004() {
}

/**
 * Removed in Lightning 8.x-2.06.
 *
 * Formerly added Panels and Panelizer permissions to content roles.
 */
function lightning_layout_update_8005() {
}

/**
 * Removes administrative privileges from layout_manager role.
 */
function lightning_layout_update_8006() {
  $role_storage = \Drupal::entityTypeManager()
    ->getStorage('user_role');

  /** @var \Drupal\user\RoleInterface[] $roles */
  $roles = $role_storage
    ->loadByProperties([
    'is_admin' => TRUE,
  ]);
  $keys = array_keys($roles);
  sort($keys);
  if ($keys == [
    'administrator',
    'layout_manager',
  ]) {
    $roles['layout_manager']
      ->setIsAdmin(FALSE)
      ->grantPermission('configure any layout')
      ->save();
  }
}

/**
 * Creates Lightning Layout settings config object and installs Entity Blocks.
 */
function lightning_layout_update_8007() {
  Config::forModule('lightning_layout')
    ->get('lightning_layout.settings')
    ->save();
  \Drupal::service('module_installer')
    ->install([
    'entity_block',
  ]);
}

/**
 * Removed in Lightning Layout 8.x-2.0.
 *
 * Formerly installed the Panelizer Quick Edit module.
 */
function lightning_layout_update_8008() {
}

/**
 * Removes the Lightning third_party_settings from Layout Manager role.
 */
function lightning_layout_update_8009() {
  $role = Role::load('layout_manager');
  if ($role) {
    $role
      ->unsetThirdPartySetting('lightning', 'bundled');
    $role
      ->save();
  }
}

/**
 * Installs the layout_builder_st module if needed.
 */
function lightning_layout_update_8010() {

  // The layout_builder_at and layout_builder_st modules cannot be installed
  // on the same time.
  // @see https://www.drupal.org/project/layout_builder_at
  // @see https://www.drupal.org/project/layout_builder_st
  $module_handler = Drupal::moduleHandler();
  if ($module_handler
    ->moduleExists('language') && !$module_handler
    ->moduleExists('layout_builder_at')) {
    Drupal::service('module_installer')
      ->install([
      'layout_builder_st',
    ]);
  }
}

/**
 * Installs the layout_builder_styles module.
 */
function lightning_layout_update_8011() {
  Drupal::service('module_installer')
    ->install([
    'layout_builder_styles',
  ]);
}

/**
 * Installs the layout_builder_restrictions module.
 */
function lightning_layout_update_8012() {
  Drupal::service('module_installer')
    ->install([
    'layout_builder_restrictions',
  ]);
}

/**
 * Installs the layout_library module.
 */
function lightning_layout_update_8013() {
  Drupal::service('module_installer')
    ->install([
    'layout_library',
  ]);
}

Functions

Namesort descending Description
lightning_layout_install Implements hook_install().
lightning_layout_update_8001 Installs default configuration for landing page content type.
lightning_layout_update_8002 Creates the layout_manager role.
lightning_layout_update_8003 Removed in Lightning 8.x-4.0.
lightning_layout_update_8004 Removed in Lightning 8.x-2.05.
lightning_layout_update_8005 Removed in Lightning 8.x-2.06.
lightning_layout_update_8006 Removes administrative privileges from layout_manager role.
lightning_layout_update_8007 Creates Lightning Layout settings config object and installs Entity Blocks.
lightning_layout_update_8008 Removed in Lightning Layout 8.x-2.0.
lightning_layout_update_8009 Removes the Lightning third_party_settings from Layout Manager role.
lightning_layout_update_8010 Installs the layout_builder_st module if needed.
lightning_layout_update_8011 Installs the layout_builder_styles module.
lightning_layout_update_8012 Installs the layout_builder_restrictions module.
lightning_layout_update_8013 Installs the layout_library module.