Run the `TalkDateUpater` service on each cron run to ensure that the next event date for each talk is up to date. Fixes #204
34 lines
685 B
Plaintext
34 lines
685 B
Plaintext
<?php
|
|
|
|
/**
|
|
* @file
|
|
* Custom code for talks pages.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Drupal\opd_talks\Service\TalkDateUpdater;
|
|
|
|
/**
|
|
* Implements hook_cron().
|
|
*/
|
|
function opd_talks_cron(): void {
|
|
$dateUpdater = Drupal::service(TalkDateUpdater::class);
|
|
$dateUpdater->__invoke();
|
|
}
|
|
|
|
/**
|
|
* Implements hook_views_data_alter().
|
|
*/
|
|
function opd_talks_views_data_alter(array &$data): void {
|
|
$data['node__field_event_date']['event_sort'] = [
|
|
'title' => t('Custom event sort'),
|
|
'group' => t('Content'),
|
|
'help' => t('Sort events by past/future, then distance from now.'),
|
|
'sort' => [
|
|
'field' => 'field_event_date_value',
|
|
'id' => 'event_sort',
|
|
]
|
|
];
|
|
}
|