function claro_preprocess_node_add_list in Drupal 10
Same name and namespace in other branches
- 8 core/themes/claro/claro.theme \claro_preprocess_node_add_list()
- 9 core/themes/claro/claro.theme \claro_preprocess_node_add_list()
Implements template_preprocess_HOOK() for node_add_list.
Makes node_add_list variables compatible with entity_add_list.
File
- core/
themes/ claro/ claro.theme, line 109 - Functions to support theming in the Claro theme.
Code
function claro_preprocess_node_add_list(&$variables) {
if (!empty($variables['content'])) {
/** @var \Drupal\node\NodeTypeInterface $type */
foreach ($variables['content'] as $type) {
$label = $type
->label();
$description = $type
->getDescription();
$type_id = $type
->id();
$add_url = Url::fromRoute('node.add', [
'node_type' => $type_id,
]);
$variables['bundles'][$type_id] = [
'label' => $label,
'add_link' => Link::fromTextAndUrl($label, $add_url),
'description' => [],
];
if (!empty($description)) {
$variables['bundles'][$type_id]['description'] = [
'#markup' => $description,
];
}
}
$variables['attributes']['class'][] = 'node-type-list';
}
}