You are here

ds.install in Display Suite 8.2

Display Suite install file.

File

ds.install
View source
<?php

/**
 * @file
 * Display Suite install file.
 */
use Drupal\Core\Entity\Entity\EntityViewDisplay;

/**
 * Implements hook_install().
 */
function ds_install() {
  module_set_weight('ds', 1);
}

/**
 * Disable adding entity, bundle, view mode classes per display.
 */
function ds_update_8001() {

  /** @var \Drupal\Core\Entity\Display\EntityDisplayInterface $display */
  foreach (EntityViewDisplay::loadMultiple() as $display) {
    $ds = $display
      ->getThirdPartySetting('ds', 'layout');
    if (!empty($ds)) {
      $ds['entity_classes'] = 'old_view_mode';
      $display
        ->setThirdPartySetting('ds', 'layout', $ds)
        ->save();
    }
  }
}

/**
 * Fix ds_switch being added to each content entity.
 */
function ds_update_8002() {
  $entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  $entity_types = \Drupal::entityTypeManager()
    ->getDefinitions();
  foreach ($entity_types as $entity_type_id => $entity_type) {
    if ($entity_type
      ->getGroup() == 'content' && $entity_type_id != 'node') {
      if ($entity_definition_update_manager
        ->getEntityType($entity_type_id)) {
        $storage_definition = $entity_definition_update_manager
          ->getFieldStorageDefinition('ds_switch', $entity_type_id);
        if ($storage_definition) {
          $entity_definition_update_manager
            ->uninstallFieldStorageDefinition($storage_definition);
        }
      }
    }
  }
}

Functions

Namesort descending Description
ds_install Implements hook_install().
ds_update_8001 Disable adding entity, bundle, view mode classes per display.
ds_update_8002 Fix ds_switch being added to each content entity.