FlashBagInterface.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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\Flash;
  11. use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
  12. /**
  13. * FlashBagInterface.
  14. *
  15. * @author Drak <drak@zikula.org>
  16. */
  17. interface FlashBagInterface extends SessionBagInterface
  18. {
  19. /**
  20. * Adds a flash message for the given type.
  21. *
  22. * @param mixed $message
  23. */
  24. public function add(string $type, $message);
  25. /**
  26. * Registers one or more messages for a given type.
  27. *
  28. * @param string|array $messages
  29. */
  30. public function set(string $type, $messages);
  31. /**
  32. * Gets flash messages for a given type.
  33. *
  34. * @param string $type Message category type
  35. * @param array $default Default value if $type does not exist
  36. *
  37. * @return array
  38. */
  39. public function peek(string $type, array $default = []);
  40. /**
  41. * Gets all flash messages.
  42. *
  43. * @return array
  44. */
  45. public function peekAll();
  46. /**
  47. * Gets and clears flash from the stack.
  48. *
  49. * @param array $default Default value if $type does not exist
  50. *
  51. * @return array
  52. */
  53. public function get(string $type, array $default = []);
  54. /**
  55. * Gets and clears flashes from the stack.
  56. *
  57. * @return array
  58. */
  59. public function all();
  60. /**
  61. * Sets all flash messages.
  62. */
  63. public function setAll(array $messages);
  64. /**
  65. * Has flash messages for a given type?
  66. *
  67. * @return bool
  68. */
  69. public function has(string $type);
  70. /**
  71. * Returns a list of all defined types.
  72. *
  73. * @return array
  74. */
  75. public function keys();
  76. }