Version 1
[yaffs-website] / web / core / lib / Drupal / Core / Config / ConfigInstallerInterface.php
1 <?php
2
3 namespace Drupal\Core\Config;
4
5 /**
6  * Interface for classes that install config.
7  */
8 interface ConfigInstallerInterface {
9
10   /**
11    * Installs the default configuration of a given extension.
12    *
13    * When an extension is installed, it searches all the default configuration
14    * directories for all other extensions to locate any configuration with its
15    * name prefix. For example, the Node module provides the frontpage view as a
16    * default configuration file:
17    * core/modules/node/config/install/views.view.frontpage.yml
18    * When the Views module is installed after the Node module is already
19    * enabled, the frontpage view will be installed.
20    *
21    * Additionally, the default configuration directory for the extension being
22    * installed is searched to discover if it contains default configuration
23    * that is owned by other enabled extensions. So, the frontpage view will also
24    * be installed when the Node module is installed after Views.
25    *
26    * @param string $type
27    *   The extension type; e.g., 'module' or 'theme'.
28    * @param string $name
29    *   The name of the module or theme to install default configuration for.
30    *
31    * @see \Drupal\Core\Config\ExtensionInstallStorage
32    */
33   public function installDefaultConfig($type, $name);
34
35   /**
36    * Installs optional configuration.
37    *
38    * Optional configuration is only installed if:
39    * - the configuration does not exist already.
40    * - it's a configuration entity.
41    * - its dependencies can be met.
42    *
43    * @param \Drupal\Core\Config\StorageInterface $storage
44    *   (optional) The configuration storage to search for optional
45    *   configuration. If not provided, all enabled extension's optional
46    *   configuration directories will be searched.
47    * @param array $dependency
48    *   (optional) If set, ensures that the configuration being installed has
49    *   this dependency. The format is dependency type as the key ('module',
50    *   'theme', or 'config') and the dependency name as the value
51    *   ('book', 'bartik', 'views.view.frontpage').
52    */
53   public function installOptionalConfig(StorageInterface $storage = NULL, $dependency = []);
54
55   /**
56    * Installs all default configuration in the specified collection.
57    *
58    * The function is useful if the site needs to respond to an event that has
59    * just created another collection and we need to check all the installed
60    * extensions for any matching configuration. For example, if a language has
61    * just been created.
62    *
63    * @param string $collection
64    *   The configuration collection.
65    */
66   public function installCollectionDefaultConfig($collection);
67
68   /**
69    * Sets the configuration storage that provides the default configuration.
70    *
71    * @param \Drupal\Core\Config\StorageInterface $storage
72    *
73    * @return $this
74    */
75   public function setSourceStorage(StorageInterface $storage);
76
77   /**
78    * Sets the status of the isSyncing flag.
79    *
80    * @param bool $status
81    *   The status of the sync flag.
82    *
83    * @return $this
84    */
85   public function setSyncing($status);
86
87   /**
88    * Gets the syncing state.
89    *
90    * @return bool
91    *   Returns TRUE is syncing flag set.
92    */
93   public function isSyncing();
94
95   /**
96    * Checks the configuration that will be installed for an extension.
97    *
98    * @param string $type
99    *   Type of extension to install.
100    * @param string $name
101    *   Name of extension to install.
102    *
103    * @throws \Drupal\Core\Config\UnmetDependenciesException
104    * @throws \Drupal\Core\Config\PreExistingConfigException
105    */
106   public function checkConfigurationToInstall($type, $name);
107
108 }