You are here

function template_preprocess_bat_booking_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_booking/bat_booking.module, line 193

Code

function template_preprocess_bat_booking_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_booking.add', [
          'booking_bundle' => $type
            ->id(),
        ])),
      ];
    }
  }
}