0156d6eea8086d7ecefab1ad3b142c1ed14b29ca
[yaffs-website] / src / Plugin / Provider / Custom.php
1 <?php
2 /**
3  * @file
4  * Contains \Drupal\bootstrap\Plugin\Provider\Custom.
5  */
6
7 namespace Drupal\bootstrap\Plugin\Provider;
8
9 use Drupal\bootstrap\Annotation\BootstrapProvider;
10 use Drupal\Core\Annotation\Translation;
11
12 /**
13  * The "custom" CDN provider plugin.
14  *
15  * @ingroup plugins_provider
16  *
17  * @BootstrapProvider(
18  *   id = "custom",
19  *   label = @Translation("Custom"),
20  * )
21  */
22 class Custom extends ProviderBase {
23
24   /**
25    * {@inheritdoc}
26    */
27   public function getAssets($types = NULL) {
28     $this->assets = [];
29
30     // If no type is set, return all CSS and JS.
31     if (!isset($types)) {
32       $types = ['css', 'js'];
33     }
34     $types = is_array($types) ? $types : [$types];
35
36     foreach ($types as $type) {
37       if ($setting = $this->theme->getSetting('cdn_custom_' . $type)) {
38         $this->assets[$type][] = $setting;
39       }
40       if ($setting = $this->theme->getSetting('cdn_custom_' . $type . '_min')) {
41         $this->assets['min'][$type][] = $setting;
42       }
43     }
44     return parent::getAssets($types);
45   }
46
47 }