in modules/quanthub_core/src/Plugin/FullcalendarViewProcessor/ReleaseTypeProcessor.php [20:51]
public function process(array &$variables) {
/** @var \Drupal\views\ViewExecutable $view */
$view = $variables['view'];
$view_index = key($variables['#attached']['drupalSettings']['fullCalendarView']);
$calendar_options = json_decode($variables['#attached']['drupalSettings']['fullCalendarView'][$view_index]['calendar_options'], TRUE);
// Nothing to do if there are no events to process.
if (empty($calendar_options['events'])) {
return;
}
$entries = $calendar_options['events'];
foreach ($view->result as $key => $row) {
$current_entity = $row->_entity;
$release_type = $current_entity->get('field_release_type')->value;
if (!empty($entries[$key])) {
$entries[$key]['backgroundColor'] = match($release_type) {
// @todo Set colors from the UI.
'dataset' => '#0B8043',
'press_release' => '#3F51B5',
'report_submission' => '#83226D',
'announcement' => '#CC2E4F',
'other' => '#616161',
default => '#616161'
};
}
}
// Update the entries.
if ($entries) {
$calendar_options['events'] = $entries;
$variables['#attached']['drupalSettings']['fullCalendarView'][$view_index]['calendar_options'] = json_encode($calendar_options);
}
}