diff --git a/src/Controller/CalendarController.php b/src/Controller/CalendarController.php index c27883b..8570f11 100644 --- a/src/Controller/CalendarController.php +++ b/src/Controller/CalendarController.php @@ -36,15 +36,9 @@ class CalendarController extends ControllerBase { public function calendarTitle($ebundle) { $bundle = ebundle_split($ebundle, 'bundle'); - $titlePrefix = $bundle; - $entityTypeManager = \Drupal::service('entity_type.manager'); - $contentTypes = $entityTypeManager->getStorage('node_type')->loadMultiple(); - foreach ($contentTypes as $contentType) { - if($contentType->id() == $bundle) { - $titlePrefix = $contentType->label(); - break; - } - } + $type = ebundle_split($ebundle, 'type'); + $bundles = \Drupal::service('entity_type.bundle.info')->getBundleInfo($type); + $titlePrefix = isset($bundles[$bundle]) ? $bundles[$bundle]['label'] : $bundle; return t('@bundle Calendar', array('@bundle' => ucwords($titlePrefix))); }