function LayoutBuilderEntityViewDisplay::getQuickEditSectionComponent

Returns the Quick Edit formatter settings.

Return value

\Drupal\layout_builder\SectionComponent|null The section component if it is available.

See also

\Drupal\layout_builder\QuickEditIntegration::entityViewAlter()

\Drupal\quickedit\MetadataGenerator::generateFieldMetadata()

1 call to LayoutBuilderEntityViewDisplay::getQuickEditSectionComponent()
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 520

Class

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

Namespace

Drupal\layout_builder\Entity

Code

private function getQuickEditSectionComponent() {
    // To determine the Quick Edit view_mode ID we need an originalMode set.
    if ($original_mode = $this->getOriginalMode()) {
        $parts = explode('-', $original_mode);
        // The Quick Edit view mode ID is created by
        // \Drupal\layout_builder\QuickEditIntegration::entityViewAlter()
        // concatenating together the information we need to retrieve the Layout
        // Builder component. It follows the structure prescribed by the
        // documentation of hook_quickedit_render_field().
        if (count($parts) === 6 && $parts[0] === 'layout_builder') {
            list(, $delta, $component_uuid, $entity_id) = QuickEditIntegration::deconstructViewModeId($original_mode);
            $entity = $this->entityTypeManager()
                ->getStorage($this->getTargetEntityTypeId())
                ->load($entity_id);
            $sections = $this->getEntitySections($entity);
            if (isset($sections[$delta])) {
                $component = $sections[$delta]->getComponent($component_uuid);
                $plugin = $component->getPlugin();
                // We only care about FieldBlock because these are only components
                // that provide Quick Edit integration: Quick Edit enables in-place
                // editing of fields of entities, not of anything else.
                if ($plugin instanceof DerivativeInspectionInterface && $plugin->getBaseId() === 'field_block') {
                    return $component;
                }
            }
        }
    }
    return NULL;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.