Skip to content
Snippets Groups Projects
Commit ce3281da authored by Owen Bush's avatar Owen Bush
Browse files

Add alter hooks for a number of settings.

parent 0e540104
No related branches found
No related tags found
No related merge requests found
<?php
/**
* @file
* Custom hooks exposed by the recurring_events module.
*/
/**
* Alter the time options available when creating an event series entity.
*
* @param array $times
* An array of times in the format h:i a.
*/
function hook_recurring_events_times_alter(array &$times = []) {
// Events cannot occur at midnight.
unset($times['00:00 am']);
}
/**
* Alter the duration options available when creating an event series entity.
*
* @param array $durations
* An array of durations in seconds.
*/
function hook_recurring_events_durations_alter(array &$durations = []) {
// Events can last for 2 days.
$durations[172800] = t('2 days');
}
/**
* Alter the days options available when creating an event series entity.
*
* @param array $days
* An array of available days.
*/
function hook_recurring_events_days_alter(array &$days = []) {
// No events can take place on sundays.
unset($days['sunday']);
}
/**
* Alter the month days options available when creating an event series entity.
*
* @param array $month_days
* An array of available days of the month.
*/
function hook_recurring_events_month_days_alter(array &$month_days = []) {
// No events can take place on the 17th of a month.
unset($month_days[17]);
}
......@@ -137,7 +137,7 @@ class MonthlyRecurringDateWidget extends WeeklyRecurringDateWidget {
$days[-1] = t('Last');
// TODO: Add hook ability to modify these days.
\Drupal::moduleHandler()->alter('recurring_events_month_days', $days);
return $days;
}
......
......@@ -142,7 +142,7 @@ class WeeklyRecurringDateWidget extends DateRangeDefaultWidget {
$times[$time_option->format('h:i a')] = $time_option->format($format);
}
// TODO: Add hook ability to modify these times.
\Drupal::moduleHandler()->alter('recurring_events_times', $times);
return $times;
}
......@@ -189,7 +189,7 @@ class WeeklyRecurringDateWidget extends DateRangeDefaultWidget {
'86400' => t('24 hours'),
];
// TODO: Add hook ability to modify these durations.
\Drupal::moduleHandler()->alter('recurring_events_durations', $durations);
return $durations;
}
......@@ -215,7 +215,7 @@ class WeeklyRecurringDateWidget extends DateRangeDefaultWidget {
'sunday' => t('Sunday'),
];
// TODO: Add hook ability to modify these days.
\Drupal::moduleHandler()->alter('recurring_events_days', $days);
return $days;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment