You are here

public function DefaultContentHandler::importDefaultContent in Fixed Block Content 8

Sets the current content of the custom block as the fixed default content.

Parameters

\Drupal\fixed_block_content\FixedBlockContentInterface $fixed_block: The fixed block to work with.

Overrides DefaultContentHandlerInterface::importDefaultContent

File

src/DefaultContentHandler.php, line 127

Class

DefaultContentHandler
Fixed block content default content handler.

Namespace

Drupal\fixed_block_content

Code

public function importDefaultContent(FixedBlockContentInterface $fixed_block) {

  // Set the internal link domain.
  // @todo take this value from config
  $this->linkManager
    ->setLinkDomain('http://fixed_block_content.drupal.org');
  $fixed_block
    ->set('default_content', $this->serializer
    ->serialize($fixed_block
    ->getBlockContent(), 'hal_json', [
    'fixed_block_content' => $fixed_block,
  ]));

  // Restore HAL link domain to default.
  $this->linkManager
    ->setLinkDomain('');
}