function seven_preprocess_block_content_add_list in Drupal 9
Same name and namespace in other branches
- 8 core/themes/seven/seven.theme \seven_preprocess_block_content_add_list()
Implements hook_preprocess_HOOK() for block content add list templates.
Displays the list of available custom block types for creation, adding separate variables for the label and url.
File
- core/
themes/ seven/ seven.theme, line 80 - Functions to support theming in the Seven theme.
Code
function seven_preprocess_block_content_add_list(&$variables) {
if (!empty($variables['content'])) {
foreach ($variables['content'] as $type) {
$variables['types'][$type
->id()]['label'] = $type
->label();
$options = [
'query' => \Drupal::request()->query
->all(),
];
$variables['types'][$type
->id()]['url'] = Url::fromRoute('block_content.add_form', [
'block_content_type' => $type
->id(),
], $options)
->toString();
}
}
}