function 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\CacheCode
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;
      }
    }
  }
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
