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

3
src/Controller/ReservePermissions.php

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

Loading…
Cancel
Save