You are here

protected function LayoutBuilderIsActiveCacheContext::getDisplay in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/src/Cache/LayoutBuilderIsActiveCacheContext.php \Drupal\layout_builder\Cache\LayoutBuilderIsActiveCacheContext::getDisplay()
  2. 9 core/modules/layout_builder/src/Cache/LayoutBuilderIsActiveCacheContext.php \Drupal\layout_builder\Cache\LayoutBuilderIsActiveCacheContext::getDisplay()

Returns the entity view display for a given entity type and view mode.

Parameters

string $entity_type_id: The entity type ID.

Return value

\Drupal\layout_builder\Entity\LayoutEntityDisplayInterface|null The entity view display, if it exists.

2 calls to LayoutBuilderIsActiveCacheContext::getDisplay()
LayoutBuilderIsActiveCacheContext::getCacheableMetadata in core/modules/layout_builder/src/Cache/LayoutBuilderIsActiveCacheContext.php
Gets the cacheability metadata for the context based on the parameter value.
LayoutBuilderIsActiveCacheContext::getContext in core/modules/layout_builder/src/Cache/LayoutBuilderIsActiveCacheContext.php
Returns the string representation of the cache context.

File

core/modules/layout_builder/src/Cache/LayoutBuilderIsActiveCacheContext.php, line 84

Class

LayoutBuilderIsActiveCacheContext
Determines whether Layout Builder is active for a given entity type or not.

Namespace

Drupal\layout_builder\Cache

Code

protected function getDisplay($entity_type_id) {
  if ($entity = $this->routeMatch
    ->getParameter($entity_type_id)) {
    if ($entity instanceof FieldableEntityInterface) {

      // @todo Expand to work for all view modes in
      //   https://www.drupal.org/node/2907413.
      $view_mode = 'full';
      $display = EntityViewDisplay::collectRenderDisplay($entity, $view_mode);
      if ($display instanceof LayoutEntityDisplayInterface) {
        return $display;
      }
    }
  }
}