You are here

protected function FixedBlockContent::newBlockContent in Fixed Block Content 8

Creates a new block content.

Return value

\Drupal\block_content\BlockContentInterface The new block content.

2 calls to FixedBlockContent::newBlockContent()
FixedBlockContent::exportDefaultContent in src/Entity/FixedBlockContent.php
Export the default content stored in config to the content block.
FixedBlockContent::setBlockContent in src/Entity/FixedBlockContent.php
Links a block content with this fixed block.

File

src/Entity/FixedBlockContent.php, line 152

Class

FixedBlockContent
Configuration entity for the fixed block content.

Namespace

Drupal\fixed_block_content\Entity

Code

protected function newBlockContent() {

  /** @var \Drupal\block_content\BlockContentInterface $block_content */
  $block_content = $this
    ->getBlockContentStorage()
    ->create([
    'type' => $this->block_content_bundle,
    'info' => $this->title,
    'langcode' => $this
      ->languageManager()
      ->getDefaultLanguage()
      ->getId(),
  ]);
  $block_content
    ->enforceIsNew(TRUE);
  $block_content
    ->setNewRevision(FALSE);

  // Set the reusable flag in the new custom block according to the non
  // reusable option in the fixed block content.
  $block_content
    ->set('reusable', !$this
    ->isProtected());
  return $block_content;
}