Version 1
[yaffs-website] / web / themes / contrib / bootstrap / src / Plugin / ProviderManager.php
1 <?php
2 /**
3  * @file
4  * Contains \Drupal\bootstrap\Plugin\ProviderManager.
5  */
6
7 namespace Drupal\bootstrap\Plugin;
8
9 use Drupal\bootstrap\Plugin\Provider\ProviderInterface;
10 use Drupal\bootstrap\Theme;
11
12 /**
13  * Manages discovery and instantiation of Bootstrap CDN providers.
14  *
15  * @ingroup plugins_provider
16  */
17 class ProviderManager extends PluginManager {
18   /**
19    * The base file system path for CDN providers.
20    *
21    * @var string
22    */
23   const FILE_PATH = 'public://bootstrap/provider';
24
25   /**
26    * Constructs a new \Drupal\bootstrap\Plugin\ProviderManager object.
27    *
28    * @param \Drupal\bootstrap\Theme $theme
29    *   The theme to use for discovery.
30    */
31   public function __construct(Theme $theme) {
32     parent::__construct($theme, 'Plugin/Provider', 'Drupal\bootstrap\Plugin\Provider\ProviderInterface', 'Drupal\bootstrap\Annotation\BootstrapProvider');
33     $this->setCacheBackend(\Drupal::cache('discovery'), 'theme:' . $theme->getName() . ':provider', $this->getCacheTags());
34   }
35
36   /**
37    * {@inheritdoc}
38    */
39   public function processDefinition(&$definition, $plugin_id) {
40     parent::processDefinition($definition, $plugin_id);
41     /** @var ProviderInterface $provider */
42     $provider = new $definition['class'](['theme' => $this->theme], $plugin_id, $definition);
43     $provider->processDefinition($definition, $plugin_id);
44   }
45
46 }