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(), ])); } } /** * AJAX callback for reloading CDN provider elements. * * @param array $form * Nested array of form elements that comprise the form. * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. */ public static function ajaxCallback(array $form, FormStateInterface $form_state) { return $form['advanced']['cdn'][$form_state->getValue('cdn_provider', Bootstrap::getTheme()->getSetting('cdn_provider'))]; } }