function LayoutEntityHelperTrait::originalEntityUsesDefaultStorage

Same name in other branches
  1. 9 core/modules/layout_builder/src/LayoutEntityHelperTrait.php \Drupal\layout_builder\LayoutEntityHelperTrait::originalEntityUsesDefaultStorage()
  2. 8.9.x core/modules/layout_builder/src/LayoutEntityHelperTrait.php \Drupal\layout_builder\LayoutEntityHelperTrait::originalEntityUsesDefaultStorage()
  3. 10 core/modules/layout_builder/src/LayoutEntityHelperTrait.php \Drupal\layout_builder\LayoutEntityHelperTrait::originalEntityUsesDefaultStorage()

Determines if the original entity used the default section storage.

This method can be used during the entity save process to determine whether the original entity is set and used the default section storage plugin as determined by ::getSectionStorageForEntity().

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity.

Return value

bool TRUE if the original entity used the default storage.

2 calls to LayoutEntityHelperTrait::originalEntityUsesDefaultStorage()
InlineBlockEntityOperations::handlePreSave in core/modules/layout_builder/src/InlineBlockEntityOperations.php
Handles saving a parent entity.
InlineBlockEntityOperations::removeUnusedForEntityOnSave in core/modules/layout_builder/src/InlineBlockEntityOperations.php
Remove all unused inline blocks on save.

File

core/modules/layout_builder/src/LayoutEntityHelperTrait.php, line 139

Class

LayoutEntityHelperTrait
Methods to help with entities using the layout builder.

Namespace

Drupal\layout_builder

Code

protected function originalEntityUsesDefaultStorage(EntityInterface $entity) {
    $section_storage = $this->getSectionStorageForEntity($entity);
    if ($section_storage instanceof OverridesSectionStorageInterface && !$entity->isNew() && $entity->getOriginal()) {
        $original_section_storage = $this->getSectionStorageForEntity($entity->getOriginal());
        return $original_section_storage instanceof DefaultsSectionStorageInterface;
    }
    return FALSE;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.