class abstract class CdnCacheTtlBase

Base class for "cdn_cache_ttl_*" settings.


Expanded class hierarchy of CdnCacheTtlBase

Related topics


abstract class CdnCacheTtlBase extends CdnProviderBase {

   * The DateFormatter service.
   * @var \Drupal\Core\Datetime\DateFormatterInterface
  static protected $dateFormatter;

   * A list of TTL options.
   * @var array
  static protected $ttlOptions;

   * {@inheritdoc}
  public function alterFormElement(Element $form, FormStateInterface $form_state, $form_id = NULL) {
    $setting = $this->getSettingElement($form, $form_state);
    $setting->setProperty('options', $this->getTtlOptions());

    // @todo This really shouldn't be here, but there isn't a great way of
    // setting this from the provider.
    if ($this->provider->getPluginId() === 'custom') {
      $setting->setProperty('disabled', TRUE);
      $setting->setProperty('description', '');
      $group = $this->getGroupElement($form, $form_state);
      $group->setProperty('description', $this->t('All caching is forced to "Forever" when using the "Custom" CDN Provider. This is because the provided Custom URLs above are used as part of the cache identifier. Anytime the above Custom URLs are modified, all of the caches are rebuilt automatically.'));

   * {@inheritdoc}
  public function autoCreateFormElement() {
    // Don't auto create these; they are created as part of CDN Provider.
    // @see \Drupal\bootstrap\Plugin\Setting\Advanced\Cdn\CdnProvider::alterFormElement()
    return FALSE;

   * Retrieves the TTL options.
  protected function getTtlOptions() {
    if (!isset(static::$ttlOptions)) {
      $dateFormatter = $this->getDateFormatter();
      $intervals = [
      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;

   * Retrieves the DateFormatter service.
   * @return \Drupal\Core\Datetime\DateFormatterInterface
   *   The DateFormatter service.
  protected function getDateFormatter() {
    if (!isset(static::$dateFormatter)) {
      static::$dateFormatter = \Drupal::service('date.formatter');
    return static::$dateFormatter;



Contains filters are case sensitive
Name Modifiers Type Description
CdnCacheTtlBase::$dateFormatter static protected property The DateFormatter service.
CdnCacheTtlBase::$ttlOptions static protected property A list of TTL options.
CdnCacheTtlBase::alterFormElement public function The alter method to store the code. Overrides SettingBase::alterFormElement
CdnCacheTtlBase::autoCreateFormElement public function Indicates whether a form element should be created automatically. Overrides SettingBase::autoCreateFormElement
CdnCacheTtlBase::getDateFormatter protected function Retrieves the DateFormatter service.
CdnCacheTtlBase::getTtlOptions protected function Retrieves the TTL options.
CdnProviderBase::$provider protected property The active provider based on form value or theme setting.
CdnProviderBase::ajaxCdnProvidersCallback public static function AJAX callback for reloading CDN Providers.
CdnProviderBase::alterForm public function The alter method to store the code. Overrides SettingBase::alterForm
CdnProviderBase::checkCdnExceptions protected static function Handles any CDN Provider exceptions that may have been thrown.
CdnProviderBase::getCacheTags public function The cache tags associated with this object. Overrides SettingBase::getCacheTags
CdnProviderBase::getProvider protected function Retrieves the active CDN Provider.
CdnProviderBase::setCdnProvidersAjax protected function Sets the #ajax property to rebuild the entire CDN Providers container.
FormAutoloadFixTrait::formAutoloadFix public static function Adds the autoload fix include file to the form state.
PluginBase::$theme protected property The currently set theme object.
PluginBase::__construct public function
SettingBase::$autoUserInterface public static property
SettingBase::access public function Indicates whether a setting is accessible. Overrides SettingInterface::access
SettingBase::drupalSettings public function Determines whether a theme setting should added to drupalSettings. Overrides SettingInterface::drupalSettings
SettingBase::getDefaultValue public function Retrieves the setting's default value. Overrides SettingInterface::getDefaultValue
SettingBase::getDescription public function Retrieves the setting's description, if any. Overrides SettingInterface::getDescription
SettingBase::getElement Deprecated public function Overrides SettingInterface::getElement
SettingBase::getElementProperties public function Retrieves all the form properties from the setting definition.
SettingBase::getGroup Deprecated public function Overrides SettingInterface::getGroup
SettingBase::getGroupElement public function Retrieves the group form element the setting belongs to. Overrides SettingInterface::getGroupElement
SettingBase::getGroups public function Retrieves the setting's groups. Overrides SettingInterface::getGroups
SettingBase::getOptions public function Retrieves the settings options, if set. Overrides SettingInterface::getOptions
SettingBase::getSettingElement public function Retrieves the form element for the setting. Overrides SettingInterface::getSettingElement
SettingBase::getSettingValue protected function Retrieves the setting value used to populate the form.
SettingBase::getTitle public function Retrieves the setting's human-readable title. Overrides SettingInterface::getTitle
SettingBase::processDeprecatedValues public function Retrieves the value from other deprecated settings. Overrides SettingInterface::processDeprecatedValues
SettingBase::submitForm public static function Form submission handler. Overrides FormInterface::submitForm
SettingBase::submitFormElement public static function Form submission handler. Overrides FormInterface::submitFormElement
SettingBase::validateForm public static function Form validation handler. Overrides FormInterface::validateForm
SettingBase::validateFormElement public static function Form validation handler. Overrides FormInterface::validateFormElement