class FlashBag
FlashBag flash message container.
@author Drak <drak@zikula.org>
Hierarchy
- class \Symfony\Component\HttpFoundation\Session\Flash\FlashBag implements \Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface
Expanded class hierarchy of FlashBag
1 file declares its use of FlashBag
- Session.php in vendor/
symfony/ http-foundation/ Session/ Session.php
File
-
vendor/
symfony/ http-foundation/ Session/ Flash/ FlashBag.php, line 19
Namespace
Symfony\Component\HttpFoundation\Session\FlashView source
class FlashBag implements FlashBagInterface {
private string $name = 'flashes';
private array $flashes = [];
/**
* @param string $storageKey The key used to store flashes in the session
*/
public function __construct(string $storageKey = '_symfony_flashes') {
}
public function getName() : string {
return $this->name;
}
public function setName(string $name) : void {
$this->name = $name;
}
public function initialize(array &$flashes) : void {
$this->flashes =& $flashes;
}
public function add(string $type, mixed $message) : void {
$this->flashes[$type][] = $message;
}
public function peek(string $type, array $default = []) : array {
return $this->has($type) ? $this->flashes[$type] : $default;
}
public function peekAll() : array {
return $this->flashes;
}
public function get(string $type, array $default = []) : array {
if (!$this->has($type)) {
return $default;
}
$return = $this->flashes[$type];
unset($this->flashes[$type]);
return $return;
}
public function all() : array {
$return = $this->peekAll();
$this->flashes = [];
return $return;
}
public function set(string $type, string|array $messages) : void {
$this->flashes[$type] = (array) $messages;
}
public function setAll(array $messages) : void {
$this->flashes = $messages;
}
public function has(string $type) : bool {
return \array_key_exists($type, $this->flashes) && $this->flashes[$type];
}
public function keys() : array {
return array_keys($this->flashes);
}
public function getStorageKey() : string {
return $this->storageKey;
}
public function clear() : mixed {
return $this->all();
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
FlashBag::$flashes | private | property | ||
FlashBag::$name | private | property | ||
FlashBag::add | public | function | Adds a flash message for the given type. | Overrides FlashBagInterface::add |
FlashBag::all | public | function | Gets and clears flashes from the stack. | Overrides FlashBagInterface::all |
FlashBag::clear | public | function | Clears out data from bag. | Overrides SessionBagInterface::clear |
FlashBag::get | public | function | Gets and clears flash from the stack. | Overrides FlashBagInterface::get |
FlashBag::getName | public | function | Gets this bag's name. | Overrides SessionBagInterface::getName |
FlashBag::getStorageKey | public | function | Gets the storage key for this bag. | Overrides SessionBagInterface::getStorageKey |
FlashBag::has | public | function | Has flash messages for a given type? | Overrides FlashBagInterface::has |
FlashBag::initialize | public | function | Initializes the Bag. | Overrides SessionBagInterface::initialize |
FlashBag::keys | public | function | Returns a list of all defined types. | Overrides FlashBagInterface::keys |
FlashBag::peek | public | function | Gets flash messages for a given type. | Overrides FlashBagInterface::peek |
FlashBag::peekAll | public | function | Gets all flash messages. | Overrides FlashBagInterface::peekAll |
FlashBag::set | public | function | Registers one or more messages for a given type. | Overrides FlashBagInterface::set |
FlashBag::setAll | public | function | Sets all flash messages. | Overrides FlashBagInterface::setAll |
FlashBag::setName | public | function | ||
FlashBag::__construct | public | function |