You are here

bootstrap_layout_builder.install in Bootstrap Layout Builder 2.x

Same filename and directory in other branches
  1. 1.x bootstrap_layout_builder.install

Installation and updating routines.

File

bootstrap_layout_builder.install
View source
<?php

/**
 * @file
 * Installation and updating routines.
 */
use Drupal\Core\Config\FileStorage;
use Drupal\Core\Field\BaseFieldDefinition;

/**
 * Creates the new Bootstrap Layout Builder settings.
 */
function bootstrap_layout_builder_update_8001() {
  $path = drupal_get_path('module', 'bootstrap_layout_builder') . '/config/install';
  $source = new FileStorage($path);
  $config_name = 'bootstrap_layout_builder.settings';

  /** @var \Drupal\Core\Config\StorageInterface $active_storage */
  $active_storage = \Drupal::service('config.storage');
  $active_storage
    ->write($config_name, $source
    ->read($config_name));
}

/**
 * Import new configs for breakpoints, layouts and its options.
 */
function bootstrap_layout_builder_update_8002() {

  // Enable the new dependency modules.
  \Drupal::service('module_installer')
    ->install([
    'media_library_form_element',
    'media_library_theme_reset',
  ]);

  // Re-import the default configs.
  \Drupal::service('config.installer')
    ->installDefaultConfig('module', 'bootstrap_layout_builder');
}

/**
 * Update entity definitions, necessary if notices appear on site status page.
 */
function bootstrap_layout_builder_update_8003() {
  $blb_breakpoint_entity_type = \Drupal::entityTypeManager()
    ->getDefinition('blb_breakpoint');
  $blb_layout_entity_type = \Drupal::entityTypeManager()
    ->getDefinition('blb_layout');
  $blb_layout_option_entity_type = \Drupal::entityTypeManager()
    ->getDefinition('blb_layout_option');
  $entityUpdateManager = \Drupal::entityDefinitionUpdateManager();
  $entityUpdateManager
    ->installEntityType($blb_breakpoint_entity_type);
  $entityUpdateManager
    ->installEntityType($blb_layout_entity_type);
  $entityUpdateManager
    ->installEntityType($blb_layout_option_entity_type);
}

/**
 * Make sure that dependent Bootstrap Styles module is installed.
 */
function bootstrap_layout_builder_update_8004() {
  \Drupal::service('module_installer')
    ->install([
    'bootstrap_styles',
  ]);
}

/**
 * Add 'default_breakpoints' field to 'blb_layout_option' entities.
 */
function bootstrap_layout_builder_update_8005() {
  $field_storage_definition = BaseFieldDefinition::create('default_breakpoints')
    ->setLabel(t('Default Breakpoints'))
    ->setDescription(t('Breakpoints you want to make this layout option the default.'))
    ->setRevisionable(FALSE);
  \Drupal::entityDefinitionUpdateManager()
    ->installFieldStorageDefinition('default_breakpoints', 'blb_layout_option', 'bootstrap_layout_builder', $field_storage_definition);
}

Functions

Namesort descending Description
bootstrap_layout_builder_update_8001 Creates the new Bootstrap Layout Builder settings.
bootstrap_layout_builder_update_8002 Import new configs for breakpoints, layouts and its options.
bootstrap_layout_builder_update_8003 Update entity definitions, necessary if notices appear on site status page.
bootstrap_layout_builder_update_8004 Make sure that dependent Bootstrap Styles module is installed.
bootstrap_layout_builder_update_8005 Add 'default_breakpoints' field to 'blb_layout_option' entities.