You are here

private function NodeViewCountSettingsForm::getLogsLifeTimeOptions in Node view count 8

Get logs lifetime options.

Data returned in format applicable for '#options' key of form element. Keys are time intervals in ms, values are human readable time spans.

Return value

array Logs lifetime options.

1 call to NodeViewCountSettingsForm::getLogsLifeTimeOptions()
NodeViewCountSettingsForm::buildForm in src/Form/NodeViewCountSettingsForm.php
Form constructor.

File

src/Form/NodeViewCountSettingsForm.php, line 227

Class

NodeViewCountSettingsForm
Configure nodeviewcount settings.

Namespace

Drupal\nodeviewcount\Form

Code

private function getLogsLifeTimeOptions() {
  $life_time_options = [
    0 => $this
      ->t('Never'),
  ];
  $time_intervals = [
    86400,
    604800,
    1209600,
    2592000,
    15552000,
    31536000,
  ];
  foreach ($time_intervals as $time_interval) {
    $life_time_options[$time_interval] = $this->dateFormatter
      ->formatInterval($time_interval);
  }
  return $life_time_options;
}