class SetInlineBlockDependencyWithContextTranslation in Layout Builder Asymmetric Translation 8.2
Takes over \Drupal\layout_builder\EventSubscriber\SetInlineBlockDependency to load the entity with the correct translation.
Hierarchy
- class \Drupal\layout_builder\EventSubscriber\SetInlineBlockDependency implements \Symfony\Component\EventDispatcher\EventSubscriberInterface uses LayoutEntityHelperTrait
- class \Drupal\layout_builder_at\EventSubscriber\SetInlineBlockDependencyWithContextTranslation
Expanded class hierarchy of SetInlineBlockDependencyWithContextTranslation
File
- src/
EventSubscriber/ SetInlineBlockDependencyWithContextTranslation.php, line 12
Namespace
Drupal\layout_builder_at\EventSubscriberView source
class SetInlineBlockDependencyWithContextTranslation extends SetInlineBlockDependency {
/**
* Call getTranslationFromContext() on the entity.
*/
protected function getInlineBlockDependency(BlockContentInterface $block_content) {
$layout_entity_info = $this->usage
->getUsage($block_content
->id());
if (empty($layout_entity_info)) {
// If the block does not have usage information then we cannot set a
// dependency. It may be used by another module besides layout builder.
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;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LayoutEntityHelperTrait:: |
protected | property | The section storage manager. | 1 |
LayoutEntityHelperTrait:: |
protected | function | Gets the sections for an entity if any. | |
LayoutEntityHelperTrait:: |
protected | function | Gets components that have Inline Block plugins. | |
LayoutEntityHelperTrait:: |
protected | function | Gets revision IDs for layout sections. | |
LayoutEntityHelperTrait:: |
protected | function | Gets the section storage for an entity. | |
LayoutEntityHelperTrait:: |
protected | function | Determines if an entity is using a field for the layout override. | |
LayoutEntityHelperTrait:: |
protected | function | Determines if an entity can have a layout. | |
LayoutEntityHelperTrait:: |
protected | function | Determines if the original entity used the default section storage. | |
LayoutEntityHelperTrait:: |
private | function | Gets the section storage manager. | 1 |
SetInlineBlockDependency:: |
protected | property | The database connection. | |
SetInlineBlockDependency:: |
protected | property | The entity type manager. | |
SetInlineBlockDependency:: |
protected | property | The inline block usage service. | |
SetInlineBlockDependency:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
SetInlineBlockDependency:: |
protected | function | Determines if a block content revision is used in an entity. | |
SetInlineBlockDependency:: |
public | function | Handles the BlockContentEvents::INLINE_BLOCK_GET_DEPENDENCY event. | |
SetInlineBlockDependency:: |
public | function | Constructs SetInlineBlockDependency object. | |
SetInlineBlockDependencyWithContextTranslation:: |
protected | function |
Call getTranslationFromContext() on the entity. Overrides SetInlineBlockDependency:: |