Commit 76502a5f authored by Rajab Natshah's avatar Rajab Natshah
Browse files

Issue #3400506: Refactor updates for Varbase Layout Builder by moving hook...

Issue #3400506: Refactor updates for Varbase Layout Builder by moving hook updates to include/updates with load Include based on major branches
parent 11789804
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Contains List of all varbase_layout_builder updates.
 */

\Drupal::moduleHandler()->loadInclude('varbase_layout_builder', 'inc', 'include/updates/v8');
\Drupal::moduleHandler()->loadInclude('varbase_layout_builder', 'inc', 'include/updates/v9');

include/updates/v8.inc

0 → 100644
+47 −0
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Contains varbase_layout_builder_update_8###(s) hook updates.
 */

/**
 * Issue #3104761: Add and enable [Entity Blocks] module ( ~1.0 )
 */
function varbase_layout_builder_update_8101() {
  if (!\Drupal::moduleHandler()->moduleExists('entity_block')) {
    \Drupal::service('module_installer')->install(['entity_block'], FALSE);
  }
}

/**
 * Issue #3169416: Theme Layout Builder Modal and Media Library to look like.
 *
 * Claro admin theme.
 */
function varbase_layout_builder_update_8102() {

  if (!version_compare(\Drupal::VERSION, '8.8.0', 'lt')) {
    if (!\Drupal::service('theme_handler')->themeExists('claro')) {

      // Install Claro theme.
      \Drupal::service('theme_installer')->install(['claro'], FALSE);
    }

    if (\Drupal::moduleHandler()->moduleExists('media_library_theme_reset')) {
      \Drupal::service('module_installer')->uninstall(['media_library_theme_reset'], FALSE);
    }

    $config_factory = \Drupal::service('config.factory')->getEditable('varbase_layout_builder.settings');
    $config_factory->set('use_claro', 1)->save(TRUE);
  }
}

/**
 * Issue #3170980: Add Layout Builder Component Attributes module.
 */
function varbase_layout_builder_update_8103() {
  if (!\Drupal::moduleHandler()->moduleExists('layout_builder_component_attributes')) {
    \Drupal::service('module_installer')->install(['layout_builder_component_attributes'], FALSE);
  }
}

include/updates/v9.inc

0 → 100644
+20 −0
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Contains varbase_layout_builder_update_9###(s) hook updates.
 */

use Vardot\Installer\ModuleInstallerFactory;

/**
 * Issue #3272216: Switch to use the Module Installer Factory.
 *
 * In the Varbase Layout Builder module.
 */
function varbase_layout_builder_update_90001() {
  // Set the weight of the module after installation of list of modules.
  // To make sure that any hook or event subscriber worker
  // after all used modules.
  ModuleInstallerFactory::setModuleWeightAfterInstallation('varbase_layout_builder');
}
+2 −2
Original line number Diff line number Diff line
@@ -67,7 +67,8 @@ function vlplb_update_8101() {
 */
function vlplb_update_90001() {
  // Set the weight of the module after installation of list of modules.
  // To make sure that any hook or event subscriber workes after all used modules.
  // To make sure that any hook or event subscriber worker
  // after all used modules.
  ModuleInstallerFactory::setModuleWeightAfterInstallation('vlplb');
}

@@ -81,7 +82,6 @@ function vlplb_update_90002() {
  // https://git.drupalcode.org/project/pathauto/-/blob/8.x-1.10/pathauto.install#L304
  // Based on the following comment:
  // https://www.drupal.org/project/pathauto/issues/2925169#comment-14636138

  // Load all pattern configuration entities.
  foreach (\Drupal::configFactory()->listAll('pathauto.pattern.') as $pattern_config_name) {
    $pattern_config = \Drupal::configFactory()->getEditable($pattern_config_name);
+3 −52
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ use Vardot\Installer\ModuleInstallerFactory;
 */
function varbase_layout_builder_install() {

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

@@ -24,54 +24,5 @@ function varbase_layout_builder_install() {

}

/**
 * Issue #3104761: Add and enable [Entity Blocks] module ( ~1.0 )
 */
function varbase_layout_builder_update_8101() {
  if (!\Drupal::moduleHandler()->moduleExists('entity_block')) {
    \Drupal::service('module_installer')->install(['entity_block'], FALSE);
  }
}

/**
 * Issue #3169416: Theme Layout Builder Modal and Media Library to look like.
 *
 * Claro admin theme.
 */
function varbase_layout_builder_update_8102() {

  if (!version_compare(\Drupal::VERSION, '8.8.0', 'lt')) {
    if (!\Drupal::service('theme_handler')->themeExists('claro')) {

      // Install Claro theme.
      \Drupal::service('theme_installer')->install(['claro'], FALSE);
    }

    if (\Drupal::moduleHandler()->moduleExists('media_library_theme_reset')) {
      \Drupal::service('module_installer')->uninstall(['media_library_theme_reset'], FALSE);
    }

    $config_factory = \Drupal::service('config.factory')->getEditable('varbase_layout_builder.settings');
    $config_factory->set('use_claro', 1)->save(TRUE);
  }
}

/**
 * Issue #3170980: Add Layout Builder Component Attributes module.
 */
function varbase_layout_builder_update_8103() {
  if (!\Drupal::moduleHandler()->moduleExists('layout_builder_component_attributes')) {
    \Drupal::service('module_installer')->install(['layout_builder_component_attributes'], FALSE);
  }
}

/**
 * Issue #3272216: Switch to use the Module Installer Factory.
 *
 * In the Varbase Layout Builder module.
 */
function varbase_layout_builder_update_90001() {
  // Set the weight of the module after installation of list of modules.
  // To make sure that any hook or event subscriber workes after all used modules.
  ModuleInstallerFactory::setModuleWeightAfterInstallation('varbase_layout_builder');
}
// Load include all updates and apply them.
\Drupal::moduleHandler()->loadInclude('varbase_layout_builder', 'inc', 'include/updates/all');
Loading