You are here

protected function DateRecurDefaultRRule::_hrFormatList in Recurring Dates Field 8

Format a variable-length list into a sentence style string.

Like this, for a list with 4 items: A, B, C and D Or with 2 items: A and B

Parameters

string[] $list:

Return value

\Drupal\Core\StringTranslation\TranslatableMarkup

2 calls to DateRecurDefaultRRule::_hrFormatList()
DateRecurDefaultRRule::humanReadable in src/DateRecurDefaultRRule.php
Return a human readable and translated representation of the repeat rule.
DateRecurDefaultRRule::_hrFormatPosList in src/DateRecurDefaultRRule.php

File

src/DateRecurDefaultRRule.php, line 157

Class

DateRecurDefaultRRule

Namespace

Drupal\date_recur

Code

protected function _hrFormatList($list) {
  if (is_string($list)) {
    return $list;
  }
  if (count($list) == 1) {
    return $list[0];
  }
  else {
    $args['@b'] = array_pop($list);
    $args['@a'] = implode(', ', $list);
    return $this
      ->t('and', $args);
  }
}