private function LayoutBuilderEntityViewDisplay::getSectionComponentForFieldName in Drupal 10
Same name and namespace in other branches
- 8 core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php \Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay::getSectionComponentForFieldName()
- 9 core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php \Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay::getSectionComponentForFieldName()
Gets the component for a given field name if any.
Parameters
string $field_name: The field name.
Return value
\Drupal\layout_builder\SectionComponent|null The section component if it is available.
1 call to LayoutBuilderEntityViewDisplay::getSectionComponentForFieldName()
- LayoutBuilderEntityViewDisplay::getComponent in core/
modules/ layout_builder/ src/ Entity/ LayoutBuilderEntityViewDisplay.php - Gets the display options set for a component.
File
- core/
modules/ layout_builder/ src/ Entity/ LayoutBuilderEntityViewDisplay.php, line 496
Class
- LayoutBuilderEntityViewDisplay
- Provides an entity view display entity that has a layout.
Namespace
Drupal\layout_builder\EntityCode
private function getSectionComponentForFieldName($field_name) {
// Loop through every component until the first match is found.
foreach ($this
->getSections() as $section) {
foreach ($section
->getComponents() as $component) {
$plugin = $component
->getPlugin();
if ($plugin instanceof DerivativeInspectionInterface && in_array($plugin
->getBaseId(), [
'field_block',
'extra_field_block',
], TRUE)) {
// FieldBlock derivative IDs are in the format
// [entity_type]:[bundle]:[field].
[
,
,
$field_block_field_name,
] = explode(PluginBase::DERIVATIVE_SEPARATOR, $plugin
->getDerivativeId());
if ($field_block_field_name === $field_name) {
return $component;
}
}
}
}
return NULL;
}