You are here

public function PreviewFactory::getEntityDisplays in View Modes Display 8.2

Returns all display for an entity.

Parameters

string $entityTypeId: Entity id.

string $entityBundle: Entity bundle.

Return value

\Drupal\Core\Entity\EntityInterface[] Array of entity displays.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

1 call to PreviewFactory::getEntityDisplays()
PreviewFactory::preview in src/Service/PreviewFactory.php
Preview entity view modes.

File

src/Service/PreviewFactory.php, line 130

Class

PreviewFactory
Class PreviewFactory.

Namespace

Drupal\view_modes_display\Service

Code

public function getEntityDisplays($entityTypeId, $entityBundle) {
  $configPrefix = 'core.entity_view_display';
  $prefix = $configPrefix . '.' . $entityTypeId . '.' . $entityBundle . '.';
  $configKeys = $this->configFactory
    ->listAll($prefix);
  $displayKeys = [];
  foreach ($configKeys as $configKey) {
    $displayKeys[] = str_replace($configPrefix . '.', '', $configKey);
  }
  return $this->entityTypeManager
    ->getStorage('entity_view_display')
    ->loadMultiple($displayKeys);
}