QuickEditLayoutBuilderEntityViewDisplay.php in Drupal 10
File
core/modules/quickedit/src/Entity/QuickEditLayoutBuilderEntityViewDisplay.php
View source
<?php
namespace Drupal\quickedit\Entity;
use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Component\Plugin\DerivativeInspectionInterface;
use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay;
use Drupal\quickedit\LayoutBuilderIntegration;
class QuickEditLayoutBuilderEntityViewDisplay extends LayoutBuilderEntityViewDisplay {
public function getComponent($name) {
if ($this
->isLayoutBuilderEnabled() && ($section_component = $this
->getQuickEditSectionComponent())) {
$plugin = $section_component
->getPlugin();
if ($plugin instanceof ConfigurableInterface) {
$configuration = $plugin
->getConfiguration();
if (isset($configuration['formatter'])) {
return $configuration['formatter'];
}
}
}
return parent::getComponent($name);
}
private function getQuickEditSectionComponent() {
if ($original_mode = $this
->getOriginalMode()) {
$parts = explode('-', $original_mode);
if (count($parts) === 6 && $parts[0] === 'layout_builder') {
[
,
$delta,
$component_uuid,
$entity_id,
] = LayoutBuilderIntegration::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();
if ($plugin instanceof DerivativeInspectionInterface && $plugin
->getBaseId() === 'field_block') {
return $component;
}
}
}
}
return NULL;
}
}