protected function ViewsBlockArea::getBlock in Views block area 8
1 call to ViewsBlockArea::getBlock()
- ViewsBlockArea::render in src/
Plugin/ views/ area/ ViewsBlockArea.php - Render the area.
File
- src/
Plugin/ views/ area/ ViewsBlockArea.php, line 160 - Contains \Drupal\block\Plugin\views\area\Block.
Class
- ViewsBlockArea
- Provides an area handler which renders a block entity in a certain view mode.
Namespace
Drupal\views_block_area\Plugin\views\areaCode
protected function getBlock() {
if (empty($this->options['block_id'])) {
return NULL;
}
/** @var \Drupal\Core\Block\BlockManagerInterface $block_manager */
$block_manager = $this->blockManager;
/** @var \Drupal\Core\Block\BlockPluginInterface $block_instance */
$block_instance = $block_manager
->createInstance($this->options['block_id'], []);
$plugin_definition = $block_instance
->getPluginDefinition();
// Don't return broken block plugin instances.
if ($plugin_definition['id'] == 'broken') {
return NULL;
}
// Don't return broken block content instances.
if ($plugin_definition['id'] == 'block_content') {
$uuid = $block_instance
->getDerivativeId();
if (!$this->entityRepository
->loadEntityByUuid('block_content', $uuid)) {
return NULL;
}
}
return $block_instance;
}