Browse Source

initialize $bundles for perms call

8.x-1.x
Peter Lindstrom 6 years ago
parent
commit
8f60f7fbd0
  1. 4
      reserve.inc
  2. 3
      src/Controller/ReservePermissions.php

4
reserve.inc

@ -1031,6 +1031,7 @@ function reserve_yyyymmdd($month, $day) {
*
*/
function reserve_get_reserve_bundles() {
$bundles = array();
$fieldmap = \Drupal::entityManager()->getFieldMap();
foreach ($fieldmap as $entity_type => $typedef) {
foreach ($typedef as $field) {
@ -1079,13 +1080,16 @@ function ebundle_split($ebundle, $part) {
* e.g.: Room (node)
*/
function ebundles_formatted() {
$result = array();
$info = \Drupal::service("entity_type.bundle.info")->getAllBundleInfo();
$ebundles = reserve_get_reserve_bundles();
if (count($ebundles)) {
foreach ($ebundles as $ebundle) {
$type = ebundle_split($ebundle, 'type');
$bundle = ebundle_split($ebundle, 'bundle');
$result[$ebundle] = $info[$type][$bundle]['label'] . " ($type)";
}
}
return $result;
}

3
src/Controller/ReservePermissions.php

@ -46,7 +46,7 @@ class ReservePermissions implements ContainerInjectionInterface {
$permissions = [];
$ebundles = ebundles_formatted();
if (count($ebundles)) {
foreach ($ebundles as $ebundle => $bundle) {
$permissions += [
'access calendar for ' . $ebundle => [
@ -54,6 +54,7 @@ class ReservePermissions implements ContainerInjectionInterface {
]
];
}
}
return $permissions;
}

Loading…
Cancel
Save