compose-8.x-1.x-dev/compose.install

compose.install
<?php

use Drupal\Core\Entity\Display\EntityDisplayInterface;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\field_layout\Display\EntityDisplayWithLayoutInterface;
use Drupal\Core\Config\Entity\ConfigEntityUpdater;

/**
 * Implements hook_install().
 */
function compose_install() {
  module_set_weight('compose', 10);
}

/**
 * Implements hook_uninstall().
 */
function compose_uninstall() {
  // Reset each entity display to use the one-column layout to best approximate the absence of layouts.
  $entity_save = function (EntityDisplayInterface $entity) {
    if ($entity instanceof EntityDisplayWithLayoutInterface) {
      if ($entity->getLayoutId() == 'compose_tabs') {
        $entity->setLayoutId('')->save();
      }
    }
  };
  array_map($entity_save, EntityViewDisplay::loadMultiple());
  array_map($entity_save, EntityFormDisplay::loadMultiple());
}

/**
 * Remove layout_disabled from any display plugins.
 */
function compose_update_8001(&$sandbox = NULL) {
  $entity_save = function (EntityDisplayInterface $entity) {
    if ($entity instanceof EntityDisplayWithLayoutInterface) {
      if ($entity->getLayoutId() == 'layout_disabled') {
        $entity->setLayoutId('')->save();
      }
    }
  };
  array_map($entity_save, EntityViewDisplay::loadMultiple());
  array_map($entity_save, EntityFormDisplay::loadMultiple());
}

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

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