ConfigInstallerInterface.php 3.5 KB

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