ConfigEvents.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <?php
  2. namespace Drupal\Core\Config;
  3. /**
  4. * Defines events for the configuration system.
  5. *
  6. * @see \Drupal\Core\Config\ConfigCrudEvent
  7. */
  8. final class ConfigEvents {
  9. /**
  10. * Name of the event fired when saving a configuration object.
  11. *
  12. * This event allows modules to perform an action whenever a configuration
  13. * object is saved. The event listener method receives a
  14. * \Drupal\Core\Config\ConfigCrudEvent instance.
  15. *
  16. * See hook_update_N() documentation for safe configuration API usage and
  17. * restrictions as this event will be fired when configuration is saved by
  18. * hook_update_N().
  19. *
  20. * @Event
  21. *
  22. * @see \Drupal\Core\Config\ConfigCrudEvent
  23. * @see \Drupal\Core\Config\Config::save()
  24. * @see \Drupal\Core\Config\ConfigFactory::onConfigSave()
  25. * @see hook_update_N()
  26. *
  27. * @var string
  28. */
  29. const SAVE = 'config.save';
  30. /**
  31. * Name of the event fired when deleting a configuration object.
  32. *
  33. * This event allows modules to perform an action whenever a configuration
  34. * object is deleted. The event listener method receives a
  35. * \Drupal\Core\Config\ConfigCrudEvent instance.
  36. *
  37. * See hook_update_N() documentation for safe configuration API usage and
  38. * restrictions as this event will be fired when configuration is deleted by
  39. * hook_update_N().
  40. *
  41. * @Event
  42. *
  43. * @see \Drupal\Core\Config\ConfigCrudEvent
  44. * @see \Drupal\Core\Config\Config::delete()
  45. * @see \Drupal\Core\Config\ConfigFactory::onConfigDelete()
  46. * @see hook_update_N()
  47. *
  48. * @var string
  49. */
  50. const DELETE = 'config.delete';
  51. /**
  52. * Name of the event fired when renaming a configuration object.
  53. *
  54. * This event allows modules to perform an action whenever a configuration
  55. * object's name is changed. The event listener method receives a
  56. * \Drupal\Core\Config\ConfigRenameEvent instance.
  57. *
  58. * See hook_update_N() documentation for safe configuration API usage and
  59. * restrictions as this event will be fired when configuration is renamed by
  60. * hook_update_N().
  61. *
  62. * @Event
  63. *
  64. * @see \Drupal\Core\Config\ConfigRenameEvent
  65. * @see \Drupal\Core\Config\ConfigFactoryInterface::rename()
  66. * @see hook_update_N()
  67. *
  68. * @var string
  69. */
  70. const RENAME = 'config.rename';
  71. /**
  72. * Name of the event fired when validating imported configuration.
  73. *
  74. * This event allows modules to perform additional validation operations when
  75. * configuration is being imported. The event listener method receives a
  76. * \Drupal\Core\Config\ConfigImporterEvent instance.
  77. *
  78. * @Event
  79. *
  80. * @see \Drupal\Core\Config\ConfigImporterEvent
  81. * @see \Drupal\Core\Config\ConfigImporter::validate().
  82. * @see \Drupal\Core\EventSubscriber\ConfigImportSubscriber::onConfigImporterValidate().
  83. *
  84. * @var string
  85. */
  86. const IMPORT_VALIDATE = 'config.importer.validate';
  87. /**
  88. * Name of the event fired when importing configuration to target storage.
  89. *
  90. * This event allows modules to perform additional actions when configuration
  91. * is imported. The event listener method receives a
  92. * \Drupal\Core\Config\ConfigImporterEvent instance.
  93. *
  94. * @Event
  95. *
  96. * @see \Drupal\Core\Config\ConfigImporterEvent
  97. * @see \Drupal\Core\Config\ConfigImporter::import().
  98. * @see \Drupal\Core\EventSubscriber\ConfigSnapshotSubscriber::onConfigImporterImport().
  99. *
  100. * @var string
  101. */
  102. const IMPORT = 'config.importer.import';
  103. /**
  104. * Name of event fired when missing content dependencies are detected.
  105. *
  106. * Events subscribers are fired as part of the configuration import batch.
  107. * Each subscribe should call
  108. * \Drupal\Core\Config\MissingContentEvent::resolveMissingContent() when they
  109. * address a missing dependency. To address large amounts of dependencies
  110. * subscribers can call
  111. * \Drupal\Core\Config\MissingContentEvent::stopPropagation() which will stop
  112. * calling other events and guarantee that the configuration import batch will
  113. * fire the event again to continue processing missing content dependencies.
  114. *
  115. * @see \Drupal\Core\Config\ConfigImporter::processMissingContent()
  116. * @see \Drupal\Core\Config\Importer\MissingContentEvent
  117. */
  118. const IMPORT_MISSING_CONTENT = 'config.importer.missing_content';
  119. /**
  120. * Name of event fired to collect information on all config collections.
  121. *
  122. * This event allows modules to add to the list of configuration collections
  123. * retrieved by \Drupal\Core\Config\ConfigManager::getConfigCollectionInfo().
  124. * The event listener method receives a
  125. * \Drupal\Core\Config\ConfigCollectionInfo instance.
  126. *
  127. * @Event
  128. *
  129. * @see \Drupal\Core\Config\ConfigCollectionInfo
  130. * @see \Drupal\Core\Config\ConfigManager::getConfigCollectionInfo()
  131. * @see \Drupal\Core\Config\ConfigFactoryOverrideBase
  132. *
  133. * @var string
  134. */
  135. const COLLECTION_INFO = 'config.collection_info';
  136. /**
  137. * Name of the event fired just before importing configuration.
  138. *
  139. * This event allows subscribers to modify the configuration which is about to
  140. * be imported. The event listener method receives a
  141. * \Drupal\Core\Config\StorageTransformEvent instance. This event contains a
  142. * config storage which subscribers can interact with and which will finally
  143. * be used to import the configuration from.
  144. * Together with \Drupal\Core\Config\ConfigEvents::STORAGE_TRANSFORM_EXPORT
  145. * subscribers can alter the active configuration in a config sync workflow
  146. * instead of just overriding at runtime via the config-override system.
  147. * This allows a complete customization of the workflow including additional
  148. * modules and editable configuration in different environments.
  149. *
  150. * @code
  151. * $storage = $event->getStorage();
  152. * @endcode
  153. *
  154. * This event is also fired when just viewing the difference of configuration
  155. * to be imported independently of whether the import takes place or not.
  156. * Use the \Drupal\Core\Config\ConfigEvents::IMPORT event to subscribe to the
  157. * import having taken place.
  158. *
  159. * @Event
  160. *
  161. * @see \Drupal\Core\Config\StorageTransformEvent
  162. * @see \Drupal\Core\Config\ConfigEvents::STORAGE_TRANSFORM_EXPORT
  163. * @see \Drupal\Core\Config\ImportStorageTransformer::transform
  164. *
  165. * @var string
  166. */
  167. const STORAGE_TRANSFORM_IMPORT = 'config.transform.import';
  168. /**
  169. * Name of the event fired when the export storage is used.
  170. *
  171. * This event allows subscribers to modify the configuration which is about to
  172. * be exported. The event listener method receives a
  173. * \Drupal\Core\Config\StorageTransformEvent instance. This event contains a
  174. * config storage which subscribers can interact with and which will finally
  175. * be used to export the configuration from.
  176. *
  177. * @code
  178. * $storage = $event->getStorage();
  179. * @endcode
  180. *
  181. * Typically subscribers will want to perform the reverse operation on the
  182. * storage than for \Drupal\Core\Config\ConfigEvents::STORAGE_TRANSFORM_IMPORT
  183. * to make sure successive exports and imports yield no difference.
  184. *
  185. * @Event
  186. *
  187. * @see \Drupal\Core\Config\StorageTransformEvent
  188. * @see \Drupal\Core\Config\ConfigEvents::STORAGE_TRANSFORM_IMPORT
  189. * @see \Drupal\Core\Config\ExportStorageManager::getStorage
  190. *
  191. * @var string
  192. */
  193. const STORAGE_TRANSFORM_EXPORT = 'config.transform.export';
  194. }