ConfigFactoryInterface.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. namespace Drupal\Core\Config;
  3. /**
  4. * Defines the interface for a configuration object factory.
  5. *
  6. * @ingroup config_api
  7. */
  8. interface ConfigFactoryInterface {
  9. /**
  10. * Returns an immutable configuration object for a given name.
  11. *
  12. * @param string $name
  13. * The name of the configuration object to construct.
  14. *
  15. * @return \Drupal\Core\Config\ImmutableConfig
  16. * A configuration object.
  17. */
  18. public function get($name);
  19. /**
  20. * Returns an mutable configuration object for a given name.
  21. *
  22. * Should not be used for config that will have runtime effects. Therefore it
  23. * is always loaded override free.
  24. *
  25. * @param string $name
  26. * The name of the configuration object to construct.
  27. *
  28. * @return \Drupal\Core\Config\Config
  29. * A configuration object.
  30. */
  31. public function getEditable($name);
  32. /**
  33. * Returns a list of configuration objects for the given names.
  34. *
  35. * This will pre-load all requested configuration objects does not create
  36. * new configuration objects. This method always return immutable objects.
  37. * ConfigFactoryInterface::getEditable() should be used to retrieve mutable
  38. * configuration objects, one by one.
  39. *
  40. * @param array $names
  41. * List of names of configuration objects.
  42. *
  43. * @return \Drupal\Core\Config\ImmutableConfig[]
  44. * List of successfully loaded configuration objects, keyed by name.
  45. */
  46. public function loadMultiple(array $names);
  47. /**
  48. * Resets and re-initializes configuration objects. Internal use only.
  49. *
  50. * @param string|null $name
  51. * (optional) The name of the configuration object to reset. If omitted, all
  52. * configuration objects are reset.
  53. *
  54. * @return $this
  55. */
  56. public function reset($name = NULL);
  57. /**
  58. * Renames a configuration object using the storage.
  59. *
  60. * @param string $old_name
  61. * The old name of the configuration object.
  62. * @param string $new_name
  63. * The new name of the configuration object.
  64. *
  65. * @return $this
  66. */
  67. public function rename($old_name, $new_name);
  68. /**
  69. * The cache keys associated with the state of the config factory.
  70. *
  71. * All state information that can influence the result of a get() should be
  72. * included. Typically, this includes a key for each override added via
  73. * addOverride(). This allows external code to maintain caches of
  74. * configuration data in addition to or instead of caches maintained by the
  75. * factory.
  76. *
  77. * @return array
  78. * An array of strings, used to generate a cache ID.
  79. */
  80. public function getCacheKeys();
  81. /**
  82. * Clears the config factory static cache.
  83. *
  84. * @return $this
  85. */
  86. public function clearStaticCache();
  87. /**
  88. * Gets configuration object names starting with a given prefix.
  89. *
  90. * @see \Drupal\Core\Config\StorageInterface::listAll()
  91. *
  92. * @param string $prefix
  93. * (optional) The prefix to search for. If omitted, all configuration object
  94. * names that exist are returned.
  95. *
  96. * @return array
  97. * An array containing matching configuration object names.
  98. */
  99. public function listAll($prefix = '');
  100. /**
  101. * Adds config factory override services.
  102. *
  103. * @param \Drupal\Core\Config\ConfigFactoryOverrideInterface $config_factory_override
  104. * The config factory override service to add. It is added at the end of the
  105. * priority list (lower priority relative to existing ones).
  106. */
  107. public function addOverride(ConfigFactoryOverrideInterface $config_factory_override);
  108. }