FlashBagInterface.php 1.6 KB

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