Browse Source

initialize $bundles for perms call

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

12
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,12 +1080,15 @@ 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();
foreach ($ebundles as $ebundle) {
$type = ebundle_split($ebundle, 'type');
$bundle = ebundle_split($ebundle, 'bundle');
$result[$ebundle] = $info[$type][$bundle]['label'] . " ($type)";
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;
}

15
src/Controller/ReservePermissions.php

@ -46,13 +46,14 @@ class ReservePermissions implements ContainerInjectionInterface {
$permissions = [];
$ebundles = ebundles_formatted();
foreach ($ebundles as $ebundle => $bundle) {
$permissions += [
'access calendar for ' . $ebundle => [
'title' => $this->t('Allow access to the calendar for ' . $bundle),
]
];
if (count($ebundles)) {
foreach ($ebundles as $ebundle => $bundle) {
$permissions += [
'access calendar for ' . $ebundle => [
'title' => $this->t('Allow access to the calendar for ' . $bundle),
]
];
}
}
return $permissions;

Loading…
Cancel
Save