FeaturesExtensionStoragesInterface.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace Drupal\features;
  3. use Drupal\Core\Config\InstallStorage;
  4. use Drupal\Core\Extension\Extension;
  5. /**
  6. * The FeaturesExtensionStorages provides a collection of extension storages,
  7. * one for each supported configuration directory.
  8. *
  9. * Typically this will include the install and optional directories defined by
  10. * Drupal core, but may also include any extension configuration directories
  11. * added by contributed modules.
  12. *
  13. * This class serves as a partial wrapper to
  14. * Drupal\Core\Config\StorageInterface, providing a subset of methods that can
  15. * be called to apply to all available extension storages. For example,
  16. * FeaturesExtensionStoragesInterface::read() will read an extension-provided
  17. * configuration item regardless of which extension storage directory it is
  18. * provided in.
  19. */
  20. interface FeaturesExtensionStoragesInterface {
  21. /**
  22. * Returns all registered extension storages.
  23. *
  24. * @return FeaturesInstallStorage[]
  25. * Array of install storages keyed by configuration directory.
  26. */
  27. public function getExtensionStorages();
  28. /**
  29. * Adds a storage.
  30. *
  31. * @param string $directory
  32. * (optional) The configuration directory. If omitted,
  33. * InstallStorage::CONFIG_INSTALL_DIRECTORY will be used.
  34. */
  35. public function addStorage($directory = InstallStorage::CONFIG_INSTALL_DIRECTORY);
  36. /**
  37. * Reads configuration data from the storages.
  38. *
  39. * @param string $name
  40. * The name of a configuration object to load.
  41. *
  42. * @return array|bool
  43. * The configuration data stored for the configuration object name. If no
  44. * configuration data exists for the given name, FALSE is returned.
  45. */
  46. public function read($name);
  47. /**
  48. * Gets configuration object names starting with a given prefix.
  49. *
  50. * Given the following configuration objects:
  51. * - node.type.article
  52. * - node.type.page
  53. *
  54. * Passing the prefix 'node.type.' will return an array containing the above
  55. * names.
  56. *
  57. * @param string $prefix
  58. * (optional) The prefix to search for. If omitted, all configuration object
  59. * names that exist are returned.
  60. *
  61. * @return array
  62. * An array containing matching configuration object names.
  63. */
  64. public function listAll($prefix = '');
  65. /**
  66. * Lists names of configuration objects provided by a given extension.
  67. *
  68. * If a $name and/or $namespace is specified, only matching modules will be
  69. * returned. Otherwise, all install are returned.
  70. *
  71. * @param mixed $extension
  72. * A string name of an extension or a full Extension object.
  73. *
  74. * @return array
  75. * An array of configuration object names.
  76. */
  77. public function listExtensionConfig(Extension $extension);
  78. }