function template_preprocess_bat_type_add_list in Booking and Availability Management Tools for Drupal 8
Prepares variables for list of available unit type bundles templates.
Default template: bat-type-add-list.html.twig.
Parameters
array $variables: An associative array containing:
- content: An array of unit type bundles.
File
- modules/
bat_unit/ bat_unit.module, line 84 - Manage units - Units are things that can be booked for some period of time. (e.g. rooms - but also villas bungalows, cars, drills, you-get-the-idea etc.)
Code
function template_preprocess_bat_type_add_list(&$variables) {
$variables['types'] = [];
if (!empty($variables['content'])) {
foreach ($variables['content'] as $type) {
$variables['types'][$type
->id()] = [
'type' => $type
->id(),
'add_link' => Link::fromTextAndUrl($type
->label(), new Url('entity.bat_unit_type.add', [
'type_bundle' => $type
->id(),
])),
];
}
}
}