function bat_unit_entity_operation in Booking and Availability Management Tools for Drupal 8
Implements hook_entity_operation().
File
- modules/
bat_unit/ bat_unit.module, line 799 - 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_unit_entity_operation(EntityInterface $entity) {
$operations = [];
$entity_type = $entity
->getEntityType();
if ($entity_type
->id() == 'bat_unit_type') {
if (\Drupal::currentUser()
->hasPermission('administer bat_type_bundle entities')) {
$operations['units'] = [
'title' => t('Units'),
'weight' => 1,
'url' => Url::fromUserInput('/admin/bat/config/types/type/' . $entity
->id() . '/units'),
];
}
}
return $operations;
}