You are here

public static function AccessUnpublishedForm::getDurationOptions in Access unpublished 8

Get options for the duration form.

Return value

array The form values.

2 calls to AccessUnpublishedForm::getDurationOptions()
AccessUnpublishedForm::formAlter in src/Form/AccessUnpublishedForm.php
Alter the entity form to add access unpublished elements.
SettingsForm::buildForm in src/Form/SettingsForm.php
Form constructor.

File

src/Form/AccessUnpublishedForm.php, line 158

Class

AccessUnpublishedForm
Alter the entity form to add access unpublished elements.

Namespace

Drupal\access_unpublished\Form

Code

public static function getDurationOptions() {
  $dateFormatter = \Drupal::service('date.formatter');
  $period = [
    86400,
    172800,
    345600,
    604800,
    1209600,
  ];
  $period = array_map([
    $dateFormatter,
    'formatInterval',
  ], array_combine($period, $period));
  $period[-1] = t('Unlimited');
  return $period;
}