Skip to content
Snippets Groups Projects

3457775 - Priorized block_uuid when looking for the block

Files
2
@@ -4,6 +4,7 @@ namespace Drupal\layout_builder_st\Element;
use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Component\Plugin\DerivativeInspectionInterface;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Render\Element;
use Drupal\layout_builder\Element\LayoutBuilder as CoreLayoutBuilder;
@@ -147,10 +148,23 @@ final class LayoutBuilder extends CoreLayoutBuilder {
$plugin = $component->getPlugin();
if ($plugin instanceof DerivativeInspectionInterface && $plugin->getBaseId() === 'inline_block') {
$configuration = $plugin->getConfiguration();
/** @var \Drupal\block_content\Entity\BlockContent $block */
$block = $this->entityTypeManager->getStorage('block_content')
->loadRevision($configuration['block_revision_id']);
if ($block->isTranslatable()) {
if (isset($configuration['block_uuid'])) {
$block = $this->entityTypeManager->getStorage('block_content')
->loadByProperties([
'uuid' => $configuration['block_uuid']
]);
if ($block) {
$block = current($block);
}
}
else {
$block = $this->entityTypeManager->getStorage('block_content')
->loadRevision($configuration['block_revision_id']);
}
if ($block instanceof ContentEntityInterface && $block->isTranslatable()) {
$contextual_group = 'layout_builder_inline_block_translation';
}
}
Loading