You are here

public function EntityTypeInfo::entityTypeAlter in View Modes Display 8.2

Adds preview links to appropriate entity types.

This is an alter hook bridge.

Parameters

\Drupal\Core\Entity\EntityTypeInterface[] $entity_types: The master entity type list to alter.

See also

hook_entity_type_alter()

File

src/EntityTypeInfo.php, line 67

Class

EntityTypeInfo
Manipulates entity type information.

Namespace

Drupal\view_modes_display

Code

public function entityTypeAlter(array &$entity_types) {
  foreach ($entity_types as $entity_type_id => $entity_type) {
    if ($viewModes = $this->entityDisplayRepository
      ->getViewModes($entity_type_id)) {
      $entity_type
        ->setLinkTemplate('vmd-preview-list', "/{$entity_type_id}/{{$entity_type_id}}/view-mode/preview/list");
      $entity_type
        ->setLinkTemplate('vmd-preview-list', "/{$entity_type_id}/{{$entity_type_id}}/view-mode/preview/{view_mode}");
    }
  }
}