You are here

public function LayoutBuilderEntityViewDisplay::getComponent in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php \Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay::getComponent()

Gets the display options set for a component.

Parameters

string $name: The name of the component.

Return value

array|null The display options for the component, or NULL if the component is not displayed.

Overrides EntityDisplayBase::getComponent

File

core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php, line 498

Class

LayoutBuilderEntityViewDisplay
Provides an entity view display entity that has a layout.

Namespace

Drupal\layout_builder\Entity

Code

public function getComponent($name) {
  if ($this
    ->isLayoutBuilderEnabled() && ($section_component = $this
    ->getQuickEditSectionComponent() ?: $this
    ->getSectionComponentForFieldName($name))) {
    $plugin = $section_component
      ->getPlugin();
    if ($plugin instanceof ConfigurableInterface) {
      $configuration = $plugin
        ->getConfiguration();
      if (isset($configuration['formatter'])) {
        return $configuration['formatter'];
      }
    }
  }
  return parent::getComponent($name);
}