StateInterface.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace Drupal\Core\State;
  3. /**
  4. * Defines the interface for the state system.
  5. *
  6. * @ingroup state_api
  7. */
  8. interface StateInterface {
  9. /**
  10. * Returns the stored value for a given key.
  11. *
  12. * @param string $key
  13. * The key of the data to retrieve.
  14. * @param mixed $default
  15. * The default value to use if the key is not found.
  16. *
  17. * @return mixed
  18. * The stored value, or NULL if no value exists.
  19. */
  20. public function get($key, $default = NULL);
  21. /**
  22. * Returns the stored key/value pairs for a given set of keys.
  23. *
  24. * @param array $keys
  25. * A list of keys to retrieve.
  26. *
  27. * @return array
  28. * An associative array of items successfully returned, indexed by key.
  29. */
  30. public function getMultiple(array $keys);
  31. /**
  32. * Saves a value for a given key.
  33. *
  34. * @param string $key
  35. * The key of the data to store.
  36. * @param mixed $value
  37. * The data to store.
  38. */
  39. public function set($key, $value);
  40. /**
  41. * Saves key/value pairs.
  42. *
  43. * @param array $data
  44. * An associative array of key/value pairs.
  45. */
  46. public function setMultiple(array $data);
  47. /**
  48. * Deletes an item.
  49. *
  50. * @param string $key
  51. * The item name to delete.
  52. */
  53. public function delete($key);
  54. /**
  55. * Deletes multiple items.
  56. *
  57. * @param array $keys
  58. * A list of item names to delete.
  59. */
  60. public function deleteMultiple(array $keys);
  61. /**
  62. * Resets the static cache.
  63. *
  64. * This is mainly used in testing environments.
  65. */
  66. public function resetCache();
  67. }