ds.install in Display Suite 8.2
Same filename and directory in other branches
Display Suite install file.
File
ds.installView 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
Name | 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. |