You are here

protected function LayoutEntityHelperTrait::originalEntityUsesDefaultStorage in Drupal 8

Same name and namespace in other branches
  1. 9 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 $entity->original 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 162

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() && isset($entity->original)) {
    $original_section_storage = $this
      ->getSectionStorageForEntity($entity->original);
    return $original_section_storage instanceof DefaultsSectionStorageInterface;
  }
  return FALSE;
}