SessionStorageInterface.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpFoundation\Session\Storage;
  11. use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
  12. /**
  13. * StorageInterface.
  14. *
  15. * @author Fabien Potencier <fabien@symfony.com>
  16. * @author Drak <drak@zikula.org>
  17. *
  18. * @api
  19. */
  20. interface SessionStorageInterface
  21. {
  22. /**
  23. * Starts the session.
  24. *
  25. * @throws \RuntimeException If something goes wrong starting the session.
  26. *
  27. * @return boolean True if started.
  28. *
  29. * @api
  30. */
  31. function start();
  32. /**
  33. * Returns the session ID
  34. *
  35. * @return string The session ID or empty.
  36. *
  37. * @api
  38. */
  39. function getId();
  40. /**
  41. * Sets the session ID
  42. *
  43. * @param string $id
  44. *
  45. * @api
  46. */
  47. function setId($id);
  48. /**
  49. * Returns the session name
  50. *
  51. * @return mixed The session name.
  52. *
  53. * @api
  54. */
  55. function getName();
  56. /**
  57. * Sets the session name
  58. *
  59. * @param string $name
  60. *
  61. * @api
  62. */
  63. function setName($name);
  64. /**
  65. * Regenerates id that represents this storage.
  66. *
  67. * This method must invoke session_regenerate_id($destroy) unless
  68. * this interface is used for a storage object designed for unit
  69. * or functional testing where a real PHP session would interfere
  70. * with testing.
  71. *
  72. * Note regenerate+destroy should not clear the session data in memory
  73. * only delete the session data from persistent storage.
  74. *
  75. * @param Boolean $destroy Destroy session when regenerating?
  76. *
  77. * @return Boolean True if session regenerated, false if error
  78. *
  79. * @throws \RuntimeException If an error occurs while regenerating this storage
  80. *
  81. * @api
  82. */
  83. function regenerate($destroy = false);
  84. /**
  85. * Force the session to be saved and closed.
  86. *
  87. * This method must invoke session_write_close() unless this interface is
  88. * used for a storage object design for unit or functional testing where
  89. * a real PHP session would interfere with testing, in which case it
  90. * it should actually persist the session data if required.
  91. */
  92. function save();
  93. /**
  94. * Clear all session data in memory.
  95. */
  96. function clear();
  97. /**
  98. * Gets a SessionBagInterface by name.
  99. *
  100. * @param string $name
  101. *
  102. * @return SessionBagInterface
  103. *
  104. * @throws \InvalidArgumentException If the bag does not exist
  105. */
  106. function getBag($name);
  107. /**
  108. * Registers a SessionBagInterface for use.
  109. *
  110. * @param SessionBagInterface $bag
  111. */
  112. function registerBag(SessionBagInterface $bag);
  113. }