ezcontent-8.x-dev/ezcontent.install

ezcontent.install
<?php

/**
 * @file
 * Install, update/uninstall functions for the EZ Content profile.
 */

/**
 * Configuration changes post update of field group module to 3.x.
 */
function ezcontent_update_8001() {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('ezcontent', 'ezcontent_update_8001');

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Configuration changes for update from 1.2 to 1.3.
 */
function ezcontent_update_8002() {
  // Remove module entries from core.extension config for modules that are no
  // longer part of ezcontent profile.
  $module_data = \Drupal::config('core.extension')->get('module');
  unset($module_data['default_content'], $module_data['ezcontent_demo'], $module_data['moderation_note']);
  \Drupal::configFactory()->getEditable('core.extension')
    ->set('module', $module_data)
    ->save();
  // Remove module entries from key_value table for modules that are no longer
  // part of ezcontent profile.
  $modules = [
    'default_content',
    'ezcontent_demo',
    'moderation_note',
  ];
  \Drupal::database()->delete('key_value')
    ->condition('collection', 'system.schema')
    ->condition('name', $modules, 'IN')
    ->execute();
  // Install gin theme.
  \Drupal::service('theme_installer')->install(['gin']);
  // Install gin toolbar.
  \Drupal::service('module_installer')->install(['gin_toolbar']);
}

/**
 * Remove entries for deprecated service from database, if any.
 */
function ezcontent_update_8003() {
  // Check for all the routes in the router table and delete the ones that have
  // "paramconverter.latest_revision" service registered as a converter in the
  // parameters options for the route.
  $routes = \Drupal::database()->select('router', 'r')
    ->fields('r', ['name', 'route'])
    ->execute()->fetchAll();
  foreach ($routes as $route) {
    $unserialized_routes = $ur_options = [];
    $unserialized_routes = unserialize($route->route);
    $ur_options = $unserialized_routes->getOptions();
    if (isset($ur_options['parameters'])) {
      if (isset($ur_options['parameters'][key($ur_options['parameters'])]['converter'])
        && $ur_options['parameters'][key($ur_options['parameters'])]['converter'] === 'paramconverter.latest_revision') {
        \Drupal::database()->delete('router')
          ->condition('name', $route->name)
          ->execute();
      }
    }
  }
}

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

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