You are here

function template_preprocess_bat_unit_add_list in Booking and Availability Management Tools for Drupal 8

Prepares variables for list of available unit bundles templates.

Default template: bat-unit-add-list.html.twig.

Parameters

array $variables: An associative array containing:

  • content: An array of unit bundles.

File

modules/bat_unit/bat_unit.module, line 105
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_unit_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.add_form', [
          'unit_bundle' => $type
            ->id(),
        ])),
      ];
    }
  }
}