public static function OfficeHoursDateHelper::weekDaysOrdered in Office Hours 8
Reorders weekdays to match the first day of the week.
Parameters
array $weekdays: An array of weekdays.
Return value
array An array of weekdays reordered to match the first day of the week. The keys will remain unchanged. For example, if the first day of the week is set to be Monday, the array keys will be [1, 2, 3, 4, 5, 6, 0].
Overrides DateHelper::weekDaysOrdered
2 calls to OfficeHoursDateHelper::weekDaysOrdered()
- OfficeHoursDefaultWidget::formElement in src/
Plugin/ Field/ FieldWidget/ OfficeHoursDefaultWidget.php - Returns the form for a single field widget.
- OfficeHoursFormatterTrait::getRows in src/
OfficeHoursFormatterTrait.php - Returns the items of a field.
File
- src/
OfficeHoursDateHelper.php, line 251
Class
- OfficeHoursDateHelper
- Defines lots of helpful functions for use in massaging dates.
Namespace
Drupal\office_hoursCode
public static function weekDaysOrdered($office_hours, $first_day = '') {
$first_day = $first_day == '' ? OfficeHoursDateHelper::getFirstDay() : $first_day;
// Sort Weekdays; leave Exception days at bottom of list.
foreach ($office_hours as $key => $item) {
$new_office_hours[$key - 7 * (int) ($key >= $first_day)] = $item;
}
ksort($new_office_hours);
return $new_office_hours;
}