function claro_preprocess_block_content_add_list
Implements hook_preprocess_HOOK() for block_content_add_list.
Makes block_content_add_list variables compatible with entity_add_list.
Deprecated
in drupal:11.3.0 and is removed from drupal:12.0.0. Use entity_add_list instead.
See also
https://www.drupal.org/node/3530643
File
-
core/
themes/ claro/ claro.theme, line 172
Code
function claro_preprocess_block_content_add_list(&$variables) : void {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Use entity_add_list instead. See https://www.drupal.org/node/3530643', E_USER_DEPRECATED);
if (!empty($variables['content'])) {
$query = \Drupal::request()->query
->all();
/** @var \Drupal\block_content\BlockContentTypeInterface $type */
foreach ($variables['content'] as $type) {
$label = $type->label();
$description = $type->getDescription();
$type_id = $type->id();
$add_url = Url::fromRoute('block_content.add_form', [
'block_content_type' => $type_id,
], [
'query' => $query,
]);
$variables['bundles'][$type_id] = [
'label' => $label,
'add_link' => Link::fromTextAndUrl($label, $add_url),
'description' => [],
];
if (!empty($description)) {
$variables['bundles'][$type_id]['description'] = [
'#markup' => $description,
];
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.