function protected function CdnCacheTtlBase::getTtlOptions

8.x-3.x CdnCacheTtlBase.php protected CdnCacheTtlBase::getTtlOptions()

Retrieves the TTL options.

Class

CdnCacheTtlBase
Base class for "cdn_cache_ttl_*" settings.

Namespace

Drupal\bootstrap\Plugin\Setting\Advanced\Cdn

Source src/Plugin/Setting/Advanced/Cdn/CdnCacheTtlBase.php (line 65)

protected function getTtlOptions() {
  if (!isset(static::$ttlOptions)) {
    $dateFormatter = $this->getDateFormatter();
    $intervals = [
      ProviderInterface::TTL_NEVER,
      ProviderInterface::TTL_ONE_DAY,
      ProviderInterface::TTL_ONE_WEEK,
      ProviderInterface::TTL_ONE_MONTH,
      ProviderInterface::TTL_THREE_MONTHS,
      ProviderInterface::TTL_SIX_MONTHS,
      ProviderInterface::TTL_ONE_YEAR,
    ];
    static::$ttlOptions = array_map([$dateFormatter, 'formatInterval'], array_combine($intervals, $intervals));
    static::$ttlOptions[ProviderInterface::TTL_NEVER] = (string) $this->t('Never');
    static::$ttlOptions[ProviderInterface::TTL_FOREVER] = (string) $this->t('Forever');
  }
  return static::$ttlOptions;
}