ConfigRevertInterface.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace Drupal\config_update;
  3. /**
  4. * Defines an interface for config import and revert operations.
  5. */
  6. interface ConfigRevertInterface {
  7. /**
  8. * Name of the event triggered on configuration import.
  9. *
  10. * @see \Drupal\config_update\ConfigRevertEvent
  11. * @see \Drupal\config_update\ConfigRevertInterface::import()
  12. */
  13. const IMPORT = 'config_update.import';
  14. /**
  15. * Name of the event triggered on configuration revert.
  16. *
  17. * @see \Drupal\config_update\ConfigRevertEvent
  18. * @see \Drupal\config_update\ConfigRevertInterface::revert()
  19. */
  20. const REVERT = 'config_update.revert';
  21. /**
  22. * Imports configuration from extension storage to active storage.
  23. *
  24. * This action triggers a ConfigRevertInterface::IMPORT event if the
  25. * configuration could be imported.
  26. *
  27. * @param string $type
  28. * The type of configuration.
  29. * @param string $name
  30. * The name of the config item, without the prefix.
  31. *
  32. * @return bool
  33. * TRUE if the operation succeeded; FALSE if the configuration could not
  34. * be found to import. May also throw exceptions if there is a problem
  35. * during saving the configuration.
  36. *
  37. * @see \Drupal\config_update\ConfigRevertInterface::IMPORT
  38. */
  39. public function import($type, $name);
  40. /**
  41. * Reverts configuration to the value from extension storage.
  42. *
  43. * This action triggers a ConfigRevertInterface::REVERT event.
  44. *
  45. * @param string $type
  46. * The type of configuration.
  47. * @param string $name
  48. * The name of the config item, without the prefix.
  49. *
  50. * @return bool
  51. * TRUE if the operation succeeded; FALSE if the base configuration could
  52. * not be found to revert to. May also throw exceptions if there is a
  53. * problem during saving the configuration.
  54. *
  55. * @see \Drupal\config_update\ConfigRevertInterface::REVERT
  56. */
  57. public function revert($type, $name);
  58. /**
  59. * Gets the current active value of configuration.
  60. *
  61. * @param string $type
  62. * The type of configuration. Or pass '' to indicate that $name is the full
  63. * name.
  64. * @param string $name
  65. * The name of the config item, without the prefix.
  66. *
  67. * @return array
  68. * The configuration value.
  69. */
  70. public function getFromActive($type, $name);
  71. /**
  72. * Gets the extension storage value of configuration.
  73. *
  74. * This is the value from a file in the config/install or config/optional
  75. * directory of a module, theme, or install profile.
  76. *
  77. * @param string $type
  78. * The type of configuration. Or pass '' to indicate that $name is the full
  79. * name.
  80. * @param string $name
  81. * The name of the config item, without the prefix.
  82. *
  83. * @return array|false
  84. * The configuration value, or FALSE if it could not be located.
  85. */
  86. public function getFromExtension($type, $name);
  87. }