You are here

public function FixedToContentMappingHandler::getBlockContent in Fixed Block Content 8

Gets the block content linked with a fixed block.

Parameters

string $fixed_block_id: The ID of the fixed block.

Return value

\Drupal\block_content\BlockContentInterface|null The block content, NULL if none found.

Overrides FixedToContentMappingHandlerInterface::getBlockContent

1 call to FixedToContentMappingHandler::getBlockContent()
FixedToContentMappingHandler::setBlockContent in src/FixedToContentMappingHandler.php
Links a fixed block to a block content.

File

src/FixedToContentMappingHandler.php, line 108

Class

FixedToContentMappingHandler
Fixed block to block content mapping entity handler.

Namespace

Drupal\fixed_block_content

Code

public function getBlockContent($fixed_block_id) {

  /** @var \Drupal\Core\Database\StatementInterface $bids */
  $bids = $this->database
    ->select('fixed_block_content', 'fbc')
    ->fields('fbc', [
    'bid',
  ])
    ->range(0, 1)
    ->condition('fbc.fbid', $fixed_block_id)
    ->execute();
  if ($bid = $bids
    ->fetchField()) {
    $block_content_storage = $this->entityTypeManager
      ->getStorage('block_content');
    return $block_content_storage
      ->load($bid);
  }
  return NULL;
}