SetInlineBlockDependencyWithContextTranslation.php in Layout Builder Asymmetric Translation 8.2
File
src/EventSubscriber/SetInlineBlockDependencyWithContextTranslation.php
View source
<?php
namespace Drupal\layout_builder_at\EventSubscriber;
use Drupal\block_content\BlockContentInterface;
use Drupal\layout_builder\EventSubscriber\SetInlineBlockDependency;
class SetInlineBlockDependencyWithContextTranslation extends SetInlineBlockDependency {
protected function getInlineBlockDependency(BlockContentInterface $block_content) {
$layout_entity_info = $this->usage
->getUsage($block_content
->id());
if (empty($layout_entity_info)) {
return NULL;
}
$layout_entity_storage = $this->entityTypeManager
->getStorage($layout_entity_info->layout_entity_type);
$layout_entity = $layout_entity_storage
->load($layout_entity_info->layout_entity_id);
$layout_entity = \Drupal::service('entity.repository')
->getTranslationFromContext($layout_entity);
if ($this
->isLayoutCompatibleEntity($layout_entity)) {
if ($this
->isBlockRevisionUsedInEntity($layout_entity, $block_content)) {
return $layout_entity;
}
}
return NULL;
}
}