NullStorage.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. namespace Drupal\Core\Config;
  3. /**
  4. * Defines a stub storage.
  5. *
  6. * This storage is always empty; the controller reads and writes nothing.
  7. *
  8. * The stub implementation is needed for synchronizing configuration during
  9. * installation of a module, in which case all configuration being shipped with
  10. * the module is known to be new. Therefore, the module installation process is
  11. * able to short-circuit the full diff against the active configuration; the
  12. * diff would yield all currently available configuration as items to remove,
  13. * since they do not exist in the module's default configuration directory.
  14. *
  15. * This also can be used for testing purposes.
  16. */
  17. class NullStorage implements StorageInterface {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public function exists($name) {
  22. return FALSE;
  23. }
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function read($name) {
  28. return [];
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function readMultiple(array $names) {
  34. return [];
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function write($name, array $data) {
  40. return FALSE;
  41. }
  42. /**
  43. * {@inheritdoc}
  44. */
  45. public function delete($name) {
  46. return FALSE;
  47. }
  48. /**
  49. * {@inheritdoc}
  50. */
  51. public function rename($name, $new_name) {
  52. return FALSE;
  53. }
  54. /**
  55. * {@inheritdoc}
  56. */
  57. public function encode($data) {
  58. return $data;
  59. }
  60. /**
  61. * {@inheritdoc}
  62. */
  63. public function decode($raw) {
  64. return $raw;
  65. }
  66. /**
  67. * {@inheritdoc}
  68. */
  69. public function listAll($prefix = '') {
  70. return [];
  71. }
  72. /**
  73. * {@inheritdoc}
  74. */
  75. public function deleteAll($prefix = '') {
  76. return FALSE;
  77. }
  78. /**
  79. * {@inheritdoc}
  80. */
  81. public function createCollection($collection) {
  82. // No op.
  83. }
  84. /**
  85. * {@inheritdoc}
  86. */
  87. public function getAllCollectionNames() {
  88. return [];
  89. }
  90. /**
  91. * {@inheritdoc}
  92. */
  93. public function getCollectionName() {
  94. return '';
  95. }
  96. }