You are here

public function OverridesSectionStorage::getTempstoreKey in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php \Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage::getTempstoreKey()

Gets a string suitable for use as a tempstore key.

Return value

string A string to be used as the key for a tempstore item.

Overrides SectionStorageBase::getTempstoreKey

File

core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php, line 150

Class

OverridesSectionStorage
Defines the 'overrides' section storage type.

Namespace

Drupal\layout_builder\Plugin\SectionStorage

Code

public function getTempstoreKey() {
  $key = parent::getTempstoreKey();
  $key .= '.' . $this
    ->getContextValue('view_mode');
  $entity = $this
    ->getEntity();

  // @todo Allow entities to provide this contextual information in
  //   https://www.drupal.org/project/drupal/issues/3026957.
  if ($entity instanceof TranslatableInterface) {
    $key .= '.' . $entity
      ->language()
      ->getId();
  }
  return $key;
}