3 namespace Drupal\bootstrap\Plugin\Setting\Advanced\Cdn;
5 use Drupal\bootstrap\Utility\Element;
6 use Drupal\Core\Form\FormStateInterface;
9 * The "cdn_jsdelivr_theme" theme setting.
11 * @ingroup plugins_setting
14 * cdn_provider = "jsdelivr",
15 * id = "cdn_jsdelivr_theme",
17 * title = @Translation("Theme"),
18 * description = @Translation("Choose the example Bootstrap Theme provided by Bootstrap or one of the Bootswatch themes."),
19 * defaultValue = "bootstrap",
20 * empty_option = @Translation("Bootstrap (default)"),
21 * empty_value = "bootstrap",
23 * "advanced" = @Translation("Advanced"),
24 * "cdn" = @Translation("CDN (Content Delivery Network)"),
29 class CdnJsdelivrTheme extends CdnProvider {
34 public function alterFormElement(Element $form, FormStateInterface $form_state, $form_id = NULL) {
35 $setting = $this->getSettingElement($form, $form_state);
36 $themes = $this->provider->getThemes();
37 $version = $form_state->getValue('cdn_jsdelivr_version', $this->theme->getSetting('cdn_jsdelivr_version'));
39 $setting->setProperty('suffix', '<div id="bootstrap-theme-preview"></div>');
40 $setting->setProperty('description', t('Choose the example <a href=":bootstrap_theme" target="_blank">Bootstrap Theme</a> provided by Bootstrap or one of the many, many <a href=":bootswatch" target="_blank">Bootswatch</a> themes!', [
41 ':bootswatch' => 'https://bootswatch.com',
42 ':bootstrap_theme' => 'https://getbootstrap.com/docs/3.3/examples/theme/',
46 if (isset($themes[$version])) {
47 foreach ($themes[$version] as $theme => $data) {
48 $options[$theme] = $data['title'];
51 $setting->setProperty('options', $options);