function bat_type_access_filter in Booking and Availability Management Tools for Drupal 8
Same name and namespace in other branches
- 7 modules/bat_unit/bat_unit.module \bat_type_access_filter()
Filters types based on permissions for multiple values.
File
- modules/
bat_unit/ bat_unit.module, line 492 - 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 bat_type_access_filter($operation, $types = [], $account = NULL) {
$filtered_types = [];
// If no user object is supplied, the access check is for the current user.
if (empty($account)) {
$account = \Drupal::currentUser();
}
foreach ($types as $key => $type) {
if (bat_type_access($type, $operation, $account)) {
$filtered_types[$key] = $type;
}
}
return $filtered_types;
}