4 * Contains \Drupal\bootstrap\Plugin\Setting\Advanced\Cdn\CdnJsdelivrTheme.
7 namespace Drupal\bootstrap\Plugin\Setting\Advanced\Cdn;
9 use Drupal\bootstrap\Annotation\BootstrapSetting;
10 use Drupal\bootstrap\Utility\Element;
11 use Drupal\Core\Annotation\Translation;
12 use Drupal\Core\Form\FormStateInterface;
15 * The "cdn_jsdelivr_theme" theme setting.
17 * @ingroup plugins_setting
20 * cdn_provider = "jsdelivr",
21 * id = "cdn_jsdelivr_theme",
23 * title = @Translation("Theme"),
24 * description = @Translation("Choose the example Bootstrap Theme provided by Bootstrap or one of the Bootswatch themes."),
25 * defaultValue = "bootstrap",
26 * empty_option = @Translation("Bootstrap (default)"),
27 * empty_value = "bootstrap",
29 * "advanced" = @Translation("Advanced"),
30 * "cdn" = @Translation("CDN (Content Delivery Network)"),
35 class CdnJsdelivrTheme extends CdnProvider {
40 public function alterFormElement(Element $form, FormStateInterface $form_state, $form_id = NULL) {
41 $setting = $this->getSettingElement($form, $form_state);
42 $themes = $this->provider->getThemes();
43 $version = $form_state->getValue('cdn_jsdelivr_version', $this->theme->getSetting('cdn_jsdelivr_version'));
45 $setting->setProperty('suffix', '<div id="bootstrap-theme-preview"></div>');
46 $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!', [
47 ':bootswatch' => 'https://bootswatch.com',
48 ':bootstrap_theme' => 'http://getbootstrap.com/examples/theme/',
52 if (isset($themes[$version])) {
53 foreach ($themes[$version] as $theme => $data) {
54 $options[$theme] = $data['title'];
57 $setting->setProperty('options', $options);