public static function CalendarHelper::getCalendarDisplays in Calendar 8.2
Get views that (may) act as Calendar Display. Used to select views with other granularity to link to.
Parameters
\Drupal\views\ViewExecutable|NULL $view: The view.
Return value
array Array with view displays that have Calendar arguments.
Throws
\Exception
File
- src/
CalendarHelper.php, line 371
Class
- CalendarHelper
- Class CalendarHelper.
Namespace
Drupal\calendarCode
public static function getCalendarDisplays(ViewExecutable $view = NULL) {
$displays = $views = [];
if (!$view) {
$views_all = Drupal::entityTypeManager()
->getStorage('view')
->loadMultiple();
}
else {
$views_all[$view->storage
->id()] = Drupal::entityTypeManager()
->getStorage('view')
->load($view->storage
->id());
}
foreach ($views_all as $view_id => $all_view) {
foreach ($all_view
->get('display') as $key => $display) {
if (isset($display['display_options']['style']['type']) && $display['display_options']['style']['type'] === 'calendar') {
$view = View::load($view_id)
->getExecutable()
->executeDisplay($key);
$views[] = $view['#view'];
}
}
}
foreach ($views as $view) {
$arguments = self::getCalendarArguments($view);
if ($arguments) {
$plugin = explode('_', $arguments[0]['id']);
$displays[array_pop($plugin)] = [
'route' => 'view' . '.' . $view->storage
->id() . '.' . $view->current_display,
'title' => $view->storage
->label() . ' : ' . $view->displayHandlers
->get($view->current_display)->display['display_title'],
'view' => $view,
];
}
}
return $displays;
}