You are here

public function CdnJsdelivrVersion::alterFormElement in Express 8

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 CdnProvider::alterFormElement

File

themes/contrib/bootstrap/src/Plugin/Setting/Advanced/Cdn/CdnJsdelivrVersion.php, line 42
Contains \Drupal\bootstrap\Plugin\Setting\Advanced\Cdn\CdnJsdelivrVersion.

Class

CdnJsdelivrVersion
The "cdn_jsdelivr_version" theme setting.

Namespace

Drupal\bootstrap\Plugin\Setting\Advanced\Cdn

Code

public function alterFormElement(Element $form, FormStateInterface $form_state, $form_id = NULL) {
  $plugin_id = Html::cleanCssIdentifier($this->provider
    ->getPluginId());
  $setting = $this
    ->getSettingElement($form, $form_state);
  $setting
    ->setProperty('options', $this->provider
    ->getVersions());
  $setting
    ->setProperty('ajax', [
    'callback' => [
      get_class($this),
      'ajaxCallback',
    ],
    'wrapper' => 'cdn-provider-' . $plugin_id,
  ]);
  if (!$this->provider
    ->hasError() && !$this->provider
    ->isImported()) {
    $setting
      ->setProperty('description', t('These versions are automatically populated by the @provider API upon cache clear and newer versions may appear over time. It is highly recommended the version that the site was built with stays at that version. Until a newer version has been properly tested for updatability by the site maintainer, you should not arbitrarily "update" just because there is a newer version. This can cause many inconsistencies and undesired effects with an existing site.', [
      '@provider' => $this->provider
        ->getLabel(),
    ]));
  }
}