FlashBagInterface.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. * @return void
  23. */
  24. public function add(string $type, mixed $message);
  25. /**
  26. * Registers one or more messages for a given type.
  27. *
  28. * @return void
  29. */
  30. public function set(string $type, string|array $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. public function peek(string $type, array $default = []): array;
  38. /**
  39. * Gets all flash messages.
  40. */
  41. public function peekAll(): array;
  42. /**
  43. * Gets and clears flash from the stack.
  44. *
  45. * @param array $default Default value if $type does not exist
  46. */
  47. public function get(string $type, array $default = []): array;
  48. /**
  49. * Gets and clears flashes from the stack.
  50. */
  51. public function all(): array;
  52. /**
  53. * Sets all flash messages.
  54. *
  55. * @return void
  56. */
  57. public function setAll(array $messages);
  58. /**
  59. * Has flash messages for a given type?
  60. */
  61. public function has(string $type): bool;
  62. /**
  63. * Returns a list of all defined types.
  64. */
  65. public function keys(): array;
  66. }