protected static function WebformDateHelper::initIntervalOptions in Webform 8.5
Same name and namespace in other branches
- 6.x src/Utility/WebformDateHelper.php \Drupal\webform\Utility\WebformDateHelper::initIntervalOptions()
Initialize interval options used by submission limits.
2 calls to WebformDateHelper::initIntervalOptions()
- WebformDateHelper::getIntervalOptions in src/
Utility/ WebformDateHelper.php - Get interval options used by submission limits.
- WebformDateHelper::getIntervalOptionsFlattened in src/
Utility/ WebformDateHelper.php - Get interval options used by submission limits.
File
- src/
Utility/ WebformDateHelper.php, line 158
Class
- WebformDateHelper
- Helper class webform date helper methods.
Namespace
Drupal\webform\UtilityCode
protected static function initIntervalOptions() {
if (!isset(self::$intervalOptions)) {
$options = [
'' => t('ever'),
];
// Seconds.
$seconds_optgroup = (string) t('Second');
$increment = 0;
while ($increment < 55) {
$increment += 5;
$options[$seconds_optgroup][$increment] = t('every @increment seconds', [
'@increment' => $increment,
]);
}
// Minute.
$minute = 60;
$minute_optgroup = (string) t('Minute');
$options[$minute_optgroup][$minute] = t('every minute');
$increment = 5;
while ($increment < 55) {
$increment += 5;
$options[$minute_optgroup][$increment * $minute] = t('every @increment minutes', [
'@increment' => $increment,
]);
}
// Hour.
$hour = $minute * 60;
$hour_optgroup = (string) t('Hour');
$options[$hour_optgroup][$hour] = t('every hour');
$increment = 1;
while ($increment < 23) {
$increment += 1;
$options[$hour_optgroup][$increment * $hour] = t('every @increment hours', [
'@increment' => $increment,
]);
}
// Day.
$day = $hour * 24;
$day_optgroup = (string) t('Day');
$options[$day_optgroup][$day] = t('every day');
$increment = 1;
while ($increment < 6) {
$increment += 1;
$options[$day_optgroup][$increment * $day] = t('every @increment days', [
'@increment' => $increment,
]);
}
// Week.
$week = $day * 7;
$week_optgroup = (string) t('Week');
$options[$week_optgroup][$week] = t('every week');
$increment = 1;
while ($increment < 51) {
$increment += 1;
$options[$week_optgroup][$increment * $week] = t('every @increment weeks', [
'@increment' => $increment,
]);
}
// Year.
$year = $day * 365;
$year_optgroup = (string) t('Year');
$options[$year_optgroup][$year] = t('every year');
$increment = 1;
while ($increment < 10) {
$increment += 1;
$options[$year_optgroup][$increment * $year] = t('every @increment years', [
'@increment' => $increment,
]);
}
self::$intervalOptions = $options;
self::$intervalOptionsFlattened = OptGroup::flattenOptions($options);
}
}