You are here

varbase_landing.install in Varbase Landing Page (Paragraphs) 8.4

Install, update and uninstall functions for the Varbase landing module.

File

varbase_landing.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the Varbase landing module.
 */
use Symfony\Component\Yaml\Yaml;

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

  // Activate configurations to work with enable_multilingual.
  if (\Drupal::moduleHandler()
    ->moduleExists('varbase_internationalization')) {
    $module_path = Drupal::service('module_handler')
      ->getModule('varbase_landing')
      ->getPath() . '/config/optional/';
    $config_path = $module_path . 'language.content_settings.node.landing_page.yml';
    $config_content = file_get_contents($config_path);
    $config_data = (array) Yaml::parse($config_content);
    $config_factory = \Drupal::configFactory()
      ->getEditable('language.content_settings.node.landing_page');
    $config_factory
      ->setData($config_data)
      ->save(TRUE);
  }
}

/**
 * Enable viewsreference module.
 */
function varbase_landing_update_8001() {
  if (!\Drupal::moduleHandler()
    ->moduleExists('viewsreference')) {
    \Drupal::service('module_installer')
      ->install([
      'viewsreference',
    ], FALSE);
  }
}

/**
 * Enable entity reference revisions module.
 */
function varbase_landing_update_8002() {
  if (!\Drupal::moduleHandler()
    ->moduleExists('entity_reference_revisions')) {
    \Drupal::service('module_installer')
      ->install([
      'entity_reference_revisions',
    ], FALSE);
  }
}

/**
 * Enable viewsreference module.
 */
function varbase_landing_update_8003() {
  if (!\Drupal::moduleHandler()
    ->moduleExists('viewsreference')) {
    \Drupal::service('module_installer')
      ->install([
      'viewsreference',
    ], FALSE);
  }
}

/**
 * Enable paragraphs module.
 */
function varbase_landing_update_8004() {
  if (!\Drupal::moduleHandler()
    ->moduleExists('paragraphs')) {
    \Drupal::service('module_installer')
      ->install([
      'paragraphs',
    ], FALSE);
  }
}

/**
 * Enable Varbase Bootstrap Paragraphs module.
 */
function varbase_landing_update_8005() {
  if (!\Drupal::moduleHandler()
    ->moduleExists('varbase_bootstrap_paragraphs')) {
    \Drupal::service('module_installer')
      ->install([
      'varbase_bootstrap_paragraphs',
    ], FALSE);
  }
}

/**
 * Enable Paragraphs previewer module.
 */
function varbase_landing_update_8006() {
  if (!\Drupal::moduleHandler()
    ->moduleExists('paragraphs_previewer')) {
    \Drupal::service('module_installer')
      ->install([
      'paragraphs_previewer',
    ], FALSE);
  }
}

/**
 * Enable Paragraphs Features module.
 */
function varbase_landing_update_8007() {
  if (!\Drupal::moduleHandler()
    ->moduleExists('paragraphs_features')) {
    \Drupal::service('module_installer')
      ->install([
      'paragraphs_features',
    ], FALSE);
  }
}

/**
 * Enable Paragraphs Asymmetric Translation Widgets module.
 */
function varbase_landing_update_8008() {
  if (!\Drupal::moduleHandler()
    ->moduleExists('paragraphs_asymmetric_translation_widgets')) {
    \Drupal::service('module_installer')
      ->install([
      'paragraphs_asymmetric_translation_widgets',
    ], FALSE);
  }
}

/**
 * Updated the new default form display for the landing page content type.
 */
function varbase_landing_update_8009() {
  if (\Drupal::moduleHandler()
    ->moduleExists('paragraphs_features') && \Drupal::moduleHandler()
    ->moduleExists('paragraphs_asymmetric_translation_widgets')) {
    $module_path = Drupal::service('module_handler')
      ->getModule('varbase_landing')
      ->getPath() . '/config/install/';
    $config_path = $module_path . 'core.entity_form_display.node.landing_page.default.yml';
    $config_content = file_get_contents($config_path);
    $config_data = (array) Yaml::parse($config_content);
    $config_factory = \Drupal::configFactory()
      ->getEditable('core.entity_form_display.node.landing_page.default');
    $config_factory
      ->setData($config_data)
      ->save(TRUE);
  }
}

Functions

Namesort descending Description
varbase_landing_install Implements hook_install().
varbase_landing_update_8001 Enable viewsreference module.
varbase_landing_update_8002 Enable entity reference revisions module.
varbase_landing_update_8003 Enable viewsreference module.
varbase_landing_update_8004 Enable paragraphs module.
varbase_landing_update_8005 Enable Varbase Bootstrap Paragraphs module.
varbase_landing_update_8006 Enable Paragraphs previewer module.
varbase_landing_update_8007 Enable Paragraphs Features module.
varbase_landing_update_8008 Enable Paragraphs Asymmetric Translation Widgets module.
varbase_landing_update_8009 Updated the new default form display for the landing page content type.