You are here

function ds_entity_type_alter in Display Suite 8.4

Same name and namespace in other branches
  1. 8.2 ds.module \ds_entity_type_alter()
  2. 8.3 ds.module \ds_entity_type_alter()

Implements hook_entity_type_alter().

File

./ds.module, line 1150
Display Suite core functions.

Code

function ds_entity_type_alter(array &$entity_types) {
  if (\Drupal::moduleHandler()
    ->moduleExists('field_ui')) {

    /* @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
    foreach ($entity_types as $entity_type) {
      $base_table = $entity_type
        ->getBaseTable();
      if ($entity_type
        ->get('field_ui_base_route') && !empty($base_table)) {
        if ($entity_type
          ->hasLinkTemplate('canonical')) {
          $entity_type
            ->setLinkTemplate('display', $entity_type
            ->getLinkTemplate('canonical') . '/manage-display');
        }
      }
    }
  }

  // Undo field_layout changes to EntityViewDisplay.
  if (\Drupal::moduleHandler()
    ->moduleExists('field_layout')) {
    $entity_types['entity_view_display']
      ->setClass($entity_types['entity_view_display']
      ->getOriginalClass());
    if (\Drupal::moduleHandler()
      ->moduleExists('field_ui')) {
      $entity_types['entity_view_display']
        ->setFormClass('edit', 'Drupal\\field_ui\\Form\\EntityViewDisplayEditForm');
    }
  }
}