class FlashBag in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/http-foundation/Session/Flash/FlashBag.php \Symfony\Component\HttpFoundation\Session\Flash\FlashBag
FlashBag flash message container.
\IteratorAggregate implementation is deprecated and will be removed in 3.0.
@author Drak <drak@zikula.org>
Hierarchy
- class \Symfony\Component\HttpFoundation\Session\Flash\FlashBag implements \Symfony\Component\HttpFoundation\Session\Flash\IteratorAggregate, FlashBagInterface
Expanded class hierarchy of FlashBag
6 files declare their use of FlashBag
- FlashBagTest.php in vendor/
symfony/ http-foundation/ Tests/ Session/ Flash/ FlashBagTest.php - MockArraySessionStorageTest.php in vendor/
symfony/ http-foundation/ Tests/ Session/ Storage/ MockArraySessionStorageTest.php - MockFileSessionStorageTest.php in vendor/
symfony/ http-foundation/ Tests/ Session/ Storage/ MockFileSessionStorageTest.php - NativeSessionStorageTest.php in vendor/
symfony/ http-foundation/ Tests/ Session/ Storage/ NativeSessionStorageTest.php - Session.php in vendor/
symfony/ http-foundation/ Session/ Session.php
1 string reference to 'FlashBag'
- core.services.yml in core/
core.services.yml - core/core.services.yml
1 service uses FlashBag
File
- vendor/
symfony/ http-foundation/ Session/ Flash/ FlashBag.php, line 21
Namespace
Symfony\Component\HttpFoundation\Session\FlashView source
class FlashBag implements FlashBagInterface, \IteratorAggregate {
private $name = 'flashes';
/**
* Flash messages.
*
* @var array
*/
private $flashes = array();
/**
* The storage key for flashes in the session.
*
* @var string
*/
private $storageKey;
/**
* Constructor.
*
* @param string $storageKey The key used to store flashes in the session.
*/
public function __construct($storageKey = '_sf2_flashes') {
$this->storageKey = $storageKey;
}
/**
* {@inheritdoc}
*/
public function getName() {
return $this->name;
}
public function setName($name) {
$this->name = $name;
}
/**
* {@inheritdoc}
*/
public function initialize(array &$flashes) {
$this->flashes =& $flashes;
}
/**
* {@inheritdoc}
*/
public function add($type, $message) {
$this->flashes[$type][] = $message;
}
/**
* {@inheritdoc}
*/
public function peek($type, array $default = array()) {
return $this
->has($type) ? $this->flashes[$type] : $default;
}
/**
* {@inheritdoc}
*/
public function peekAll() {
return $this->flashes;
}
/**
* {@inheritdoc}
*/
public function get($type, array $default = array()) {
if (!$this
->has($type)) {
return $default;
}
$return = $this->flashes[$type];
unset($this->flashes[$type]);
return $return;
}
/**
* {@inheritdoc}
*/
public function all() {
$return = $this
->peekAll();
$this->flashes = array();
return $return;
}
/**
* {@inheritdoc}
*/
public function set($type, $messages) {
$this->flashes[$type] = (array) $messages;
}
/**
* {@inheritdoc}
*/
public function setAll(array $messages) {
$this->flashes = $messages;
}
/**
* {@inheritdoc}
*/
public function has($type) {
return array_key_exists($type, $this->flashes) && $this->flashes[$type];
}
/**
* {@inheritdoc}
*/
public function keys() {
return array_keys($this->flashes);
}
/**
* {@inheritdoc}
*/
public function getStorageKey() {
return $this->storageKey;
}
/**
* {@inheritdoc}
*/
public function clear() {
return $this
->all();
}
/**
* Returns an iterator for flashes.
*
* @deprecated since version 2.4, to be removed in 3.0.
*
* @return \ArrayIterator An \ArrayIterator instance
*/
public function getIterator() {
@trigger_error('The ' . __METHOD__ . ' method is deprecated since version 2.4 and will be removed in 3.0.', E_USER_DEPRECATED);
return new \ArrayIterator($this
->all());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FlashBag:: |
private | property | Flash messages. | |
FlashBag:: |
private | property | ||
FlashBag:: |
private | property | The storage key for flashes in the session. | |
FlashBag:: |
public | function |
Adds a flash message for type. Overrides FlashBagInterface:: |
|
FlashBag:: |
public | function |
Gets and clears flashes from the stack. Overrides FlashBagInterface:: |
|
FlashBag:: |
public | function |
Clears out data from bag. Overrides SessionBagInterface:: |
|
FlashBag:: |
public | function |
Gets and clears flash from the stack. Overrides FlashBagInterface:: |
|
FlashBag:: |
public | function | Returns an iterator for flashes. | |
FlashBag:: |
public | function |
Gets this bag's name. Overrides SessionBagInterface:: |
|
FlashBag:: |
public | function |
Gets the storage key for this bag. Overrides SessionBagInterface:: |
|
FlashBag:: |
public | function |
Has flash messages for a given type? Overrides FlashBagInterface:: |
|
FlashBag:: |
public | function |
Initializes the Bag. Overrides SessionBagInterface:: |
|
FlashBag:: |
public | function |
Returns a list of all defined types. Overrides FlashBagInterface:: |
|
FlashBag:: |
public | function |
Gets flash messages for a given type. Overrides FlashBagInterface:: |
|
FlashBag:: |
public | function |
Gets all flash messages. Overrides FlashBagInterface:: |
|
FlashBag:: |
public | function |
Registers a message for a given type. Overrides FlashBagInterface:: |
|
FlashBag:: |
public | function |
Sets all flash messages. Overrides FlashBagInterface:: |
|
FlashBag:: |
public | function | ||
FlashBag:: |
public | function | Constructor. |