You are here

function ds_update_8002 in Display Suite 8.3

Same name and namespace in other branches
  1. 8.4 ds.install \ds_update_8002()
  2. 8.2 ds.install \ds_update_8002()

Fix ds_switch being added to each content entity.

File

./ds.install, line 38
Display Suite install file.

Code

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);
        }
      }
    }
  }
}