protected function SetFixedBlockDependency::getFixedBlockDependency in Fixed Block Content 8
Gets the access dependent fixed block for a given custom block content.
Parameters
\Drupal\block_content\BlockContentInterface $block_content: The custom block.
Return value
\Drupal\fixed_block_content\Entity\FixedBlockContent|null The fixed block content to which the block content belongs, NULL if none found.
1 call to SetFixedBlockDependency::getFixedBlockDependency()
- SetFixedBlockDependency::onGetDependency in src/
EventSubscriber/ SetFixedBlockDependency.php - Handles the BlockContentEvents::INLINE_BLOCK_GET_DEPENDENCY event.
File
- src/
EventSubscriber/ SetFixedBlockDependency.php, line 78
Class
- SetFixedBlockDependency
- An event subscriber that sets the access dependency for fixed blocks.
Namespace
Drupal\fixed_block_content\EventSubscriberCode
protected function getFixedBlockDependency(BlockContentInterface $block_content) {
// Search the fixed block of the edited custom block.
// @todo move this to a service.
$fbids = $this->database
->select('fixed_block_content', 'fbc')
->fields('fbc', [
'fbid',
])
->range(0, 1)
->condition('fbc.bid', $block_content
->id())
->execute();
if ($fbid = $fbids
->fetchField()) {
return $this->entityTypeManager
->getStorage('fixed_block_content')
->load($fbid);
}
return NULL;
}