function public function CdnCacheTtlBase::alterFormElement

8.x-3.x CdnCacheTtlBase.php public CdnCacheTtlBase::alterFormElement(Element $form, FormStateInterface $form_state, $form_id = NULL)

The alter method to store the code.

Parameters

\Drupal\bootstrap\Utility\Element $form: The Element object that comprises the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

string $form_id: String representing the name of the form itself. Typically this is the name of the function that generated the form.

Overrides SettingBase::alterFormElement

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 39)

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.'));
  }
}