public function Calendar::build in Content Planner 8
Creates the render array for the calendar.
Return value
array The render array of the calendar.
File
- modules/
content_calendar/ src/ Component/ Calendar.php, line 98
Class
Namespace
Drupal\content_calendar\ComponentCode
public function build() {
// Build data structure first.
$calendar = $this
->buildCalendarDataStructure();
// Get nodes per node type.
$node_basic_data = [];
foreach ($this->contentTypeConfigEntities as $node_type => $config_entity) {
$node_basic_data[$node_type] = $this->contentCalendarService
->getNodesByType($node_type, [
'month' => $this->month,
'year' => $this->year,
]);
}
// Place nodes in Calendars.
$this
->placeNodesInCalendars($calendar, $node_basic_data);
// Get the weekdays based on the Drupal first day of week setting.
$build = [
'#theme' => 'content_calendar',
'#calendar' => $calendar,
'#node_type_creation_permissions' => $this
->getPermittedNodeTypeCreationActions(),
'#attached' => [
'library' => [
'content_calendar/calendar',
],
],
];
return $build;
}