function bat_unit_get_bundles in Booking and Availability Management Tools for Drupal 8
Same name and namespace in other branches
- 7 modules/bat_unit/bat_unit.module \bat_unit_get_bundles()
Gets an array of all unit bundles, keyed by the bundle name.
Parameters
string $bundle_name: If set, the bundle with the given name is returned.
bool $reset: A boolean indicating that the internal cache should be reset.
Return value
\Drupal\bat_unit\Entity\UnitBundle[] Depending whether $bundle isset, an array of unit bundles or a single one.
3 calls to bat_unit_get_bundles()
- bat_unit_bundles_ids in modules/
bat_unit/ bat_unit.module - Helper function to easily get unit bundles in an array for use in forms, etc.
- UnitAddAccessCheck::access in modules/
bat_unit/ src/ Access/ UnitAddAccessCheck.php - Checks access to the unit add page for the unit type.
- UnitPermissions::permissions in modules/
bat_unit/ src/ UnitPermissions.php - Returns an array of filter permissions.
File
- modules/
bat_unit/ bat_unit.module, line 230 - 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_get_bundles($bundle_name = NULL, $reset = FALSE) {
if ($reset) {
\Drupal::entityTypeManager()
->getStorage('bat_unit_bundle')
->resetCache();
}
$types = UnitBundle::loadMultiple();
return isset($bundle_name) ? $types[$bundle_name] : $types;
}