function template_preprocess_entity_add_list in Entity API 8.0
Prepares variables for the list of available bundles.
Default template: entity-add-list.html.twig.
Parameters
array $variables: An associative array containing:
- bundle_type: The entity type of the bundles.
- bundles: An array of bundles with the label, description, add_link keys.
File
- ./
entity.module, line 35 - Provides expanded entity APIs.
Code
function template_preprocess_entity_add_list(&$variables) {
$bundle_type = \Drupal::entityTypeManager()
->getDefinition($variables['bundle_type']);
$variables += [
'create_bundle_url' => Url::fromRoute('entity.' . $bundle_type
->id() . '.add_form')
->toString(),
'bundle_type_label' => $bundle_type
->getLowercaseLabel(),
];
foreach ($variables['bundles'] as $bundle_name => $bundle_info) {
$variables['bundles'][$bundle_name]['description'] = [
'#markup' => $bundle_info['description'],
];
}
}