protected function ChooseBlockController::getBlockLinks in Drupal 9
Same name and namespace in other branches
- 8 core/modules/layout_builder/src/Controller/ChooseBlockController.php \Drupal\layout_builder\Controller\ChooseBlockController::getBlockLinks()
Gets a render array of block links.
Parameters
\Drupal\layout_builder\SectionStorageInterface $section_storage: The section storage.
int $delta: The delta of the section to splice.
string $region: The region the block is going in.
array $blocks: The information for each block.
Return value
array The block links render array.
2 calls to ChooseBlockController::getBlockLinks()
- ChooseBlockController::build in core/
modules/ layout_builder/ src/ Controller/ ChooseBlockController.php - Provides the UI for choosing a new block.
- ChooseBlockController::inlineBlockList in core/
modules/ layout_builder/ src/ Controller/ ChooseBlockController.php - Provides the UI for choosing a new inline block.
File
- core/
modules/ layout_builder/ src/ Controller/ ChooseBlockController.php, line 223
Class
- ChooseBlockController
- Defines a controller to choose a new block.
Namespace
Drupal\layout_builder\ControllerCode
protected function getBlockLinks(SectionStorageInterface $section_storage, int $delta, $region, array $blocks) {
$links = [];
foreach ($blocks as $block_id => $block) {
$attributes = $this
->getAjaxAttributes();
$attributes['class'][] = 'js-layout-builder-block-link';
$link = [
'title' => $block['admin_label'],
'url' => Url::fromRoute('layout_builder.add_block', [
'section_storage_type' => $section_storage
->getStorageType(),
'section_storage' => $section_storage
->getStorageId(),
'delta' => $delta,
'region' => $region,
'plugin_id' => $block_id,
]),
'attributes' => $attributes,
];
$links[] = $link;
}
return [
'#theme' => 'links',
'#links' => $links,
];
}