Interim commit.
[yaffs-website] / web / modules / contrib / bootstrap_layouts / src / BootstrapLayoutsUpdateManager.php
1 <?php
2
3 namespace Drupal\bootstrap_layouts;
4
5 use Drupal\Core\Cache\CacheBackendInterface;
6 use Drupal\Core\Extension\ModuleHandlerInterface;
7 use Drupal\Core\Extension\ThemeHandlerInterface;
8 use Drupal\Core\Theme\ThemeManagerInterface;
9
10 class BootstrapLayoutsUpdateManager extends BootstrapLayoutsPluginManager {
11
12   /**
13    * Constructs a new \Drupal\bootstrap_layouts\BootstrapLayoutsManager object.
14    *
15    * @param \Traversable $namespaces
16    *   An object that implements \Traversable which contains the root paths
17    *   keyed by the corresponding namespace to look for plugin implementations.
18    * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
19    *   Cache backend instance to use.
20    * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
21    *   The module handler to invoke the alter hook with.
22    * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
23    *   The theme manager used to invoke the alter hook with.
24    * @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager
25    *   The theme manager used to invoke the alter hook with.
26    */
27   public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler, ThemeManagerInterface $theme_manager) {
28     parent::__construct($namespaces, $cache_backend, $module_handler, $theme_handler, $theme_manager, 'Drupal\bootstrap_layouts\Plugin\BootstrapLayouts\BootstrapLayoutsUpdateInterface', 'Drupal\bootstrap_layouts\Annotation\BootstrapLayoutsUpdate');
29     $this->alterInfo('bootstrap_layouts_update_info');
30     $this->setCacheBackend($cache_backend, 'bootstrap_layouts_update_info');
31   }
32
33   /**
34    * Retrieves the update plugins for a specific schema version.
35    *
36    * @param int $schema
37    *   The update schema version to retrieve.
38    *
39    * @return \Drupal\bootstrap_layouts\Plugin\BootstrapLayouts\BootstrapLayoutsUpdateInterface[]
40    *   An array of update plugins, keyed by their plugin id.
41    */
42   public function getUpdates($schema) {
43     $updates = [];
44     foreach ($this->getDefinitions() as $plugin_id => $definition) {
45       if (isset($definition['schema']) && $definition['schema'] == $schema) {
46         $updates[$plugin_id] = $this->createInstance($plugin_id);
47       }
48     }
49     return $updates;
50   }
51
52 }