public function CalendarController::showCalendarYear in Content Planner 8
Show Calendar year.
1 call to CalendarController::showCalendarYear()
- CalendarController::showCurrentCalendarYear in modules/
content_calendar/ src/ Controller/ CalendarController.php - Show Calendar year.
1 string reference to 'CalendarController::showCalendarYear'
- content_calendar.routing.yml in modules/
content_calendar/ content_calendar.routing.yml - modules/content_calendar/content_calendar.routing.yml
File
- modules/
content_calendar/ src/ Controller/ CalendarController.php, line 79
Class
- CalendarController
- Class CalendarController.
Namespace
Drupal\content_calendar\ControllerCode
public function showCalendarYear($year) {
$calendars = [];
// Get content type config entities.
$content_type_config_entities = $this->contentTypeConfigService
->loadAllEntities();
// Check if Content Calendar has been configured.
if (!$content_type_config_entities) {
$this
->messenger()
->addMessage($this
->t('Content Calendar is not configured yet. Please do this in the settings tab.'), 'error');
return [];
}
// Generate calendar structures.
foreach (range(1, 12) as $month) {
// Create new Calendar.
$calender = new Calendar($this->contentTypeConfigService, $this->contentCalendarService, $month, $year, $this->currentUser);
$calendars[] = $calender
->build();
}
// Get Filter Form.
$form_params = [
'current_year' => date('Y'),
'selected_year' => $year,
];
$filters_form = \Drupal::formBuilder()
->getForm('Drupal\\content_calendar\\Form\\CalenderOverviewFilterForm', $form_params);
if (\Drupal::currentUser()
->hasPermission('administer content calendar settings')) {
$has_permission = TRUE;
}
else {
$has_permission = FALSE;
}
$build = [
'#theme' => 'content_calendar_overview',
'#calendars' => $calendars,
'#filters_form' => $filters_form,
'#has_permission' => $has_permission,
];
return $build;
}