public static function ScheduledPublishWidget::handleEntryOrdering in Scheduled Publish 8.3
Re-orders entries and adds/changes their delta values based on date.
1 call to ScheduledPublishWidget::handleEntryOrdering()
- ScheduledPublishWidget::handleEntries in src/
Plugin/ Field/ FieldWidget/ ScheduledPublishWidget.php - Handles entry values, clean-up and ordering.
File
- src/
Plugin/ Field/ FieldWidget/ ScheduledPublishWidget.php, line 568
Class
- ScheduledPublishWidget
- Plugin implementation of the 'scheduled_publish_widget' widget.
Namespace
Drupal\scheduled_publish\Plugin\Field\FieldWidgetCode
public static function handleEntryOrdering(&$entries) {
usort($entries, function ($a, $b) {
$a_timestamp = strtotime($a['date']);
$b_timestamp = strtotime($b['date']);
if ($a_timestamp == $b_timestamp) {
return 0;
}
return $a_timestamp < $b_timestamp ? -1 : 1;
});
// Keys and delta values must always match.
foreach ($entries as $key => $entry) {
$entries[$key]['delta'] = $key;
}
}