You are here

public function BackgroundImageManager::getSupportedEntityTypes in Background Image 8

Same name and namespace in other branches
  1. 2.x src/BackgroundImageManager.php \Drupal\background_image\BackgroundImageManager::getSupportedEntityTypes()
  2. 2.0.x src/BackgroundImageManager.php \Drupal\background_image\BackgroundImageManager::getSupportedEntityTypes()

Retrieves the supported entity types.

Return value

\Drupal\Core\Entity\EntityTypeInterface[] An associative array of EntityTypeInterface objects, keyed by their machine name.

Overrides BackgroundImageManagerInterface::getSupportedEntityTypes

1 call to BackgroundImageManager::getSupportedEntityTypes()
BackgroundImageManager::getEnabledEntityTypes in src/BackgroundImageManager.php
Retrieves the enabled entity types.

File

src/BackgroundImageManager.php, line 625

Class

BackgroundImageManager

Namespace

Drupal\background_image

Code

public function getSupportedEntityTypes() {
  static $entity_types;
  if (!isset($entity_types)) {
    $allowed_entity_types = [
      'view',
    ];
    foreach ($this->entityTypeManager
      ->getDefinitions() as $entity_type) {

      // Attempt to determine if the entity type can actually display a full page.
      $full_page = $entity_type
        ->hasViewBuilderClass() && $entity_type
        ->hasLinkTemplate('canonical') && $entity_type
        ->getLinkTemplate('canonical') !== $entity_type
        ->getLinkTemplate('edit-form');
      if (in_array($entity_type
        ->id(), $allowed_entity_types) || $full_page) {
        $entity_types[$entity_type
          ->id()] = $entity_type;
      }
    }
  }
  return $entity_types;
}