You are here

protected function InlineBlock::getEntity in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/src/Plugin/Block/InlineBlock.php \Drupal\layout_builder\Plugin\Block\InlineBlock::getEntity()
  2. 10 core/modules/layout_builder/src/Plugin/Block/InlineBlock.php \Drupal\layout_builder\Plugin\Block\InlineBlock::getEntity()

Loads or creates the block content entity of the block.

Return value

\Drupal\block_content\BlockContentInterface The block content entity.

3 calls to InlineBlock::getEntity()
InlineBlock::blockAccess in core/modules/layout_builder/src/Plugin/Block/InlineBlock.php
Indicates whether the block should be shown.
InlineBlock::blockForm in core/modules/layout_builder/src/Plugin/Block/InlineBlock.php
InlineBlock::build in core/modules/layout_builder/src/Plugin/Block/InlineBlock.php
Builds and returns the renderable array for this block plugin.

File

core/modules/layout_builder/src/Plugin/Block/InlineBlock.php, line 232

Class

InlineBlock
Defines an inline block plugin type.

Namespace

Drupal\layout_builder\Plugin\Block

Code

protected function getEntity() {
  if (!isset($this->blockContent)) {
    if (!empty($this->configuration['block_serialized'])) {
      $this->blockContent = unserialize($this->configuration['block_serialized']);
    }
    elseif (!empty($this->configuration['block_revision_id'])) {
      $entity = $this->entityTypeManager
        ->getStorage('block_content')
        ->loadRevision($this->configuration['block_revision_id']);
      $this->blockContent = $entity;
    }
    else {
      $this->blockContent = $this->entityTypeManager
        ->getStorage('block_content')
        ->create([
        'type' => $this
          ->getDerivativeId(),
        'reusable' => FALSE,
      ]);
    }
    if ($this->blockContent instanceof RefinableDependentAccessInterface && ($dependee = $this
      ->getAccessDependency())) {
      $this->blockContent
        ->setAccessDependency($dependee);
    }
  }
  return $this->blockContent;
}