You are here

function node_authlink_build_options in Node authorize link 8

Helper function to build expire options.

Parameters

array $time_intervals:

int $granularity:

null $langcode:

Return value

array

1 call to node_authlink_build_options()
node_authlink_form_node_type_form_alter in ./node_authlink.module
Alter of node_type_form.

File

./node_authlink.module, line 103
Node Authlink hooks and alters.

Code

function node_authlink_build_options(array $time_intervals, $granularity = 2, $langcode = NULL) {
  $callback = function ($value) use ($granularity, $langcode) {
    return \Drupal::service('date.formatter')
      ->formatInterval($value, $granularity, $langcode);
  };
  return array_combine($time_intervals, array_map($callback, $time_intervals));
}