You are here

public static function EditUpdateForm::handleStateOrdering in Scheduled Publish 8.3

Re-orders states and adds/changes their delta values based on date.

1 call to EditUpdateForm::handleStateOrdering()
EditUpdateForm::handleStates in src/Form/EditUpdateForm.php
Handles state values, clean-up and ordering.

File

src/Form/EditUpdateForm.php, line 198
Contains \Drupal\scheduled_publish\Form\EditUpdateForm.

Class

EditUpdateForm

Namespace

Drupal\scheduled_publish\Form

Code

public static function handleStateOrdering(&$states) {
  usort($states, function ($a, $b) {
    $a_timestamp = strtotime($a['value']);
    $b_timestamp = strtotime($b['value']);
    if ($a_timestamp == $b_timestamp) {
      return 0;
    }
    return $a_timestamp < $b_timestamp ? -1 : 1;
  });
}