You are here

public function EntityTypeInfo::entityTypeAlter in Devel 8

Same name and namespace in other branches
  1. 8.3 src/EntityTypeInfo.php \Drupal\devel\EntityTypeInfo::entityTypeAlter()
  2. 8.2 src/EntityTypeInfo.php \Drupal\devel\EntityTypeInfo::entityTypeAlter()
  3. 4.x src/EntityTypeInfo.php \Drupal\devel\EntityTypeInfo::entityTypeAlter()

Adds devel 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 57

Class

EntityTypeInfo
Manipulates entity type information.

Namespace

Drupal\devel

Code

public function entityTypeAlter(array &$entity_types) {
  foreach ($entity_types as $entity_type_id => $entity_type) {
    if (($entity_type
      ->getFormClass('default') || $entity_type
      ->getFormClass('edit')) && $entity_type
      ->hasLinkTemplate('edit-form')) {
      $entity_type
        ->setLinkTemplate('devel-load', "/devel/{$entity_type_id}/{{$entity_type_id}}");
    }
    if ($entity_type
      ->hasViewBuilderClass() && $entity_type
      ->hasLinkTemplate('canonical')) {
      $entity_type
        ->setLinkTemplate('devel-render', "/devel/{$entity_type_id}/{{$entity_type_id}}/render");
    }
    if ($entity_type
      ->hasLinkTemplate('devel-render') || $entity_type
      ->hasLinkTemplate('devel-load')) {
      $entity_type
        ->setLinkTemplate('devel-definition', "/devel/{$entity_type_id}/{{$entity_type_id}}/definition");
    }
  }
}