final class InlineBlockEntityOperations in Layout Builder Symmetric Translations 8
Overrides cores InlineBlockEntityOperations to provide translation operations.
Hierarchy
- class \Drupal\layout_builder\InlineBlockEntityOperations implements ContainerInjectionInterface uses LayoutEntityHelperTrait
- class \Drupal\layout_builder_st\InlineBlockEntityOperations uses TranslationsHelperTrait
Expanded class hierarchy of InlineBlockEntityOperations
1 file declares its use of InlineBlockEntityOperations
- ClassResolver.php in src/
DependencyInjection/ ClassResolver.php
File
- src/
InlineBlockEntityOperations.php, line 12
Namespace
Drupal\layout_builder_stView source
final class InlineBlockEntityOperations extends CoreInlineBlockEntityOperations {
use TranslationsHelperTrait;
/**
* Saves a translated inline block.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity with the layout.
* @param string $component_uuid
* The component UUID.
* @param array $translated_component_configuration
* The translated component configuration.
* @param bool $new_revision
* Whether a new revision of the block should be created.
*/
protected function saveTranslatedInlineBlock(EntityInterface $entity, $component_uuid, array $translated_component_configuration, $new_revision) {
/** @var \Drupal\block_content\BlockContentInterface $block */
$block = unserialize($translated_component_configuration['block_serialized']);
// Create a InlineBlock plugin from the translated configuration in order to
// save the block.
/** @var \Drupal\layout_builder\Plugin\Block\InlineBlock $plugin */
$plugin = \Drupal::service('plugin.manager.block')
->createInstance('inline_block:' . $block
->bundle(), $translated_component_configuration);
$plugin
->saveBlockContent($new_revision);
// Remove serialized block after the block has been saved.
unset($translated_component_configuration['block_serialized']);
// Update the block_revision_id in the translated configuration which may
// have changed after saving the block.
$configuration = $plugin
->getConfiguration();
$translated_component_configuration['block_revision_id'] = $configuration['block_revision_id'];
/** @var \Drupal\layout_builder_st\TranslatableSectionStorageInterface $section_storage */
$section_storage = $this
->getSectionStorageForEntity($entity);
$section_storage
->setTranslatedComponentConfiguration($component_uuid, $translated_component_configuration);
}
/**
* {@inheritdoc}
*
* Override to ::saveTranslatedInlineBlock() for translations.
*/
protected function saveInlineBlockComponent(EntityInterface $entity, SectionComponent $component, $new_revision, $duplicate_blocks) {
$section_storage = $this
->getSectionStorageForEntity($entity);
if (static::isTranslation($section_storage)) {
/** @var \Drupal\layout_builder_st\TranslatableSectionStorageInterface $section_storage */
$translated_component_configuration = $section_storage
->getTranslatedComponentConfiguration($component
->getUuid());
if (isset($translated_component_configuration['block_serialized'])) {
$this
->saveTranslatedInlineBlock($entity, $component
->getUuid(), $translated_component_configuration, $new_revision);
}
}
else {
parent::saveInlineBlockComponent($entity, $component, $new_revision, $duplicate_blocks);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
InlineBlockEntityOperations:: |
protected | property | The block content storage. | |
InlineBlockEntityOperations:: |
protected | property | The entity type manager. | |
InlineBlockEntityOperations:: |
protected | property | Inline block usage tracking service. | |
InlineBlockEntityOperations:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
InlineBlockEntityOperations:: |
protected | function | Delete the inline blocks and the usage records. | |
InlineBlockEntityOperations:: |
protected | function | Gets blocks IDs for an array of revision IDs. | |
InlineBlockEntityOperations:: |
protected | function | Gets a block ID for an inline block plugin. | |
InlineBlockEntityOperations:: |
protected | function | Gets the IDs of the inline blocks that were removed. | |
InlineBlockEntityOperations:: |
public | function | Handles entity tracking on deleting a parent entity. | |
InlineBlockEntityOperations:: |
public | function | Handles saving a parent entity. | |
InlineBlockEntityOperations:: |
public | function | Removes unused inline blocks. | |
InlineBlockEntityOperations:: |
protected | function | Remove all unused inline blocks on save. | |
InlineBlockEntityOperations:: |
protected | function |
Override to ::saveTranslatedInlineBlock() for translations. Overrides InlineBlockEntityOperations:: |
|
InlineBlockEntityOperations:: |
protected | function | Saves a translated inline block. | |
InlineBlockEntityOperations:: |
public | function | Constructs a new EntityOperations object. | |
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 |
TranslationsHelperTrait:: |
protected static | function | Determines if the sections is for a translation. |