Open Journal Systems  3.3.0
vendor/symfony/http-foundation/Session/Flash/FlashBag.php
1 <?php
2 
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
13 
19 class FlashBag implements FlashBagInterface
20 {
21  private $name = 'flashes';
22  private $flashes = [];
23  private $storageKey;
24 
28  public function __construct(string $storageKey = '_symfony_flashes')
29  {
30  $this->storageKey = $storageKey;
31  }
32 
36  public function getName()
37  {
38  return $this->name;
39  }
40 
41  public function setName($name)
42  {
43  $this->name = $name;
44  }
45 
49  public function initialize(array &$flashes)
50  {
51  $this->flashes = &$flashes;
52  }
53 
57  public function add($type, $message)
58  {
59  $this->flashes[$type][] = $message;
60  }
61 
65  public function peek($type, array $default = [])
66  {
67  return $this->has($type) ? $this->flashes[$type] : $default;
68  }
69 
73  public function peekAll()
74  {
75  return $this->flashes;
76  }
77 
81  public function get($type, array $default = [])
82  {
83  if (!$this->has($type)) {
84  return $default;
85  }
86 
87  $return = $this->flashes[$type];
88 
89  unset($this->flashes[$type]);
90 
91  return $return;
92  }
93 
97  public function all()
98  {
99  $return = $this->peekAll();
100  $this->flashes = [];
101 
102  return $return;
103  }
104 
108  public function set($type, $messages)
109  {
110  $this->flashes[$type] = (array) $messages;
111  }
112 
116  public function setAll(array $messages)
117  {
118  $this->flashes = $messages;
119  }
120 
124  public function has($type)
125  {
126  return \array_key_exists($type, $this->flashes) && $this->flashes[$type];
127  }
128 
132  public function keys()
133  {
134  return array_keys($this->flashes);
135  }
136 
140  public function getStorageKey()
141  {
142  return $this->storageKey;
143  }
144 
148  public function clear()
149  {
150  return $this->all();
151  }
152 }
Symfony\Component\HttpFoundation\Session\Flash\FlashBag\peek
peek($type, array $default=[])
Definition: vendor/symfony/http-foundation/Session/Flash/FlashBag.php:65
Symfony\Component\HttpFoundation\Session\Flash\FlashBag\getStorageKey
getStorageKey()
Definition: vendor/symfony/http-foundation/Session/Flash/FlashBag.php:140
Symfony\Component\HttpFoundation\Session\Flash\FlashBag\has
has($type)
Definition: lib/vendor/symfony/http-foundation/Session/Flash/FlashBag.php:144
Symfony\Component\HttpFoundation\Session\Flash\FlashBag\keys
keys()
Definition: vendor/symfony/http-foundation/Session/Flash/FlashBag.php:132
Symfony\Component\HttpFoundation\Session\Flash\FlashBag\clear
clear()
Definition: vendor/symfony/http-foundation/Session/Flash/FlashBag.php:148
Symfony\Component\HttpFoundation\Session\Flash\FlashBag\setName
setName($name)
Definition: vendor/symfony/http-foundation/Session/Flash/FlashBag.php:41
Symfony\Component\HttpFoundation\Session\Flash\FlashBag\__construct
__construct(string $storageKey='_symfony_flashes')
Definition: vendor/symfony/http-foundation/Session/Flash/FlashBag.php:28
Symfony\Component\HttpFoundation\Session\Flash\FlashBag\getName
getName()
Definition: vendor/symfony/http-foundation/Session/Flash/FlashBag.php:36
Symfony\Component\HttpFoundation\Session\Flash
Definition: lib/vendor/symfony/http-foundation/Session/Flash/AutoExpireFlashBag.php:12
Symfony\Component\HttpFoundation\Session\Flash\FlashBag\setAll
setAll(array $messages)
Definition: vendor/symfony/http-foundation/Session/Flash/FlashBag.php:116
Symfony\Component\HttpFoundation\Session\Flash\FlashBag\all
all()
Definition: vendor/symfony/http-foundation/Session/Flash/FlashBag.php:97
Symfony\Component\HttpFoundation\Session\Flash\FlashBag\add
add($type, $message)
Definition: vendor/symfony/http-foundation/Session/Flash/FlashBag.php:57
Symfony\Component\HttpFoundation\Session\Flash\FlashBag\peekAll
peekAll()
Definition: vendor/symfony/http-foundation/Session/Flash/FlashBag.php:73
Symfony\Component\HttpFoundation\Session\Flash\FlashBag\initialize
initialize(array &$flashes)
Definition: vendor/symfony/http-foundation/Session/Flash/FlashBag.php:49