varbase_layout_builder-9.0.0-alpha2/varbase_layout_builder.install

varbase_layout_builder.install
<?php

/**
 * @file
 * Install, update and uninstall functions for Varbase Layout Builder module.
 */

use Drupal\Core\Config\InstallStorage;
use Vardot\Entity\EntityDefinitionUpdateManager;
use Vardot\Installer\ModuleInstallerFactory;

// Include all helpers and updates.
include_once __DIR__ . '/includes/helpers.inc';
include_once __DIR__ . '/includes/updates.inc';

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

  // Processor for install: in varbase_layout_builder.info.yml file.
  ModuleInstallerFactory::installList('varbase_layout_builder');

  // Remove BLB layout options to use VLB layout options.
  $blb_layout_options = \Drupal::service('config.factory')->listAll($prefix = "bootstrap_layout_builder.layout_option.blb_");
  foreach ($blb_layout_options as $blb_layout_option) {
    \Drupal::service('config.factory')->getEditable($blb_layout_option)->delete();
  }

  // Remove BLB breakpoints to use VLB breakpoints.
  $blb_breakpoints = \Drupal::service('config.factory')->listAll($prefix = "bootstrap_layout_builder.breakpoint.");
  foreach ($blb_breakpoints as $blb_breakpoint) {
    \Drupal::service('config.factory')->getEditable($blb_breakpoint)->delete();
  }

  // Have the .settings.yml configs into the active config.
  ModuleInstallerFactory::importConfigsFromScanedDirectory('varbase_layout_builder', '/^.*(settings.yml)$/i');

  // Have the list of layout builder style options configs into active config.
  ModuleInstallerFactory::importConfigsFromScanedDirectory('varbase_layout_builder', '/^layout_builder.style.options.*\\.(yml)$/i');

  // Add permissions.
  ModuleInstallerFactory::addPermissions('varbase_layout_builder');

  // Entity updates to clear up any mismatched entity and/or field definitions
  // And Fix changes were detected in the entity type and field definitions.
  \Drupal::classResolver()
    ->getInstanceFromDefinition(EntityDefinitionUpdateManager::class)
    ->applyUpdates();

  // Have forced configs import.
  $forced_configs = [
    'views.view.section_library',
  ];

  ModuleInstallerFactory::importConfigsFromList('varbase_layout_builder', $forced_configs, InstallStorage::CONFIG_OPTIONAL_DIRECTORY);

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc