ConfigInstallerInterface.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 will be searched.
  43. * @param array $dependency
  44. * (optional) If set, ensures that the configuration being installed has
  45. * this dependency. The format is dependency type as the key ('module',
  46. * 'theme', or 'config') and the dependency name as the value
  47. * ('book', 'bartik', 'views.view.frontpage').
  48. */
  49. public function installOptionalConfig(StorageInterface $storage = NULL, $dependency = []);
  50. /**
  51. * Installs all default configuration in the specified collection.
  52. *
  53. * The function is useful if the site needs to respond to an event that has
  54. * just created another collection and we need to check all the installed
  55. * extensions for any matching configuration. For example, if a language has
  56. * just been created.
  57. *
  58. * @param string $collection
  59. * The configuration collection.
  60. */
  61. public function installCollectionDefaultConfig($collection);
  62. /**
  63. * Sets the configuration storage that provides the default configuration.
  64. *
  65. * @param \Drupal\Core\Config\StorageInterface $storage
  66. *
  67. * @return $this
  68. */
  69. public function setSourceStorage(StorageInterface $storage);
  70. /**
  71. * Sets the status of the isSyncing flag.
  72. *
  73. * @param bool $status
  74. * The status of the sync flag.
  75. *
  76. * @return $this
  77. */
  78. public function setSyncing($status);
  79. /**
  80. * Gets the syncing state.
  81. *
  82. * @return bool
  83. * Returns TRUE is syncing flag set.
  84. */
  85. public function isSyncing();
  86. /**
  87. * Checks the configuration that will be installed for an extension.
  88. *
  89. * @param string $type
  90. * Type of extension to install.
  91. * @param string $name
  92. * Name of extension to install.
  93. *
  94. * @throws \Drupal\Core\Config\UnmetDependenciesException
  95. * @throws \Drupal\Core\Config\PreExistingConfigException
  96. */
  97. public function checkConfigurationToInstall($type, $name);
  98. }