21 private $name =
'flashes';
28 private $flashes = array(
'display' => array(),
'new' => array());
42 public function __construct($storageKey =
'_sf2_flashes')
44 $this->storageKey = $storageKey;
65 $this->flashes = &$flashes;
70 $this->flashes[
'display'] = array_key_exists(
'new', $this->flashes) ? $this->flashes[
'new'] : array();
71 $this->flashes[
'new'] = array();
77 public function add($type, $message)
79 $this->flashes[
'new'][$type][] = $message;
85 public function peek($type, array $default = array())
87 return $this->
has($type) ? $this->flashes[
'display'][$type] : $default;
95 return array_key_exists(
'display', $this->flashes) ? (array) $this->flashes[
'display'] : array();
101 public function get($type, array $default = array())
105 if (!$this->
has($type)) {
109 if (isset($this->flashes[
'display'][$type])) {
110 $return = $this->flashes[
'display'][$type];
111 unset($this->flashes[
'display'][$type]);
120 public function all()
122 $return = $this->flashes[
'display'];
123 $this->flashes = array(
'new' => array(),
'display' => array());
131 public function setAll(array $messages)
133 $this->flashes[
'new'] = $messages;
139 public function set($type, $messages)
141 $this->flashes[
'new'][$type] = (array) $messages;
147 public function has($type)
149 return array_key_exists($type, $this->flashes[
'display']) && $this->flashes[
'display'][$type];
155 public function keys()
157 return array_keys($this->flashes[
'display']);
165 return $this->storageKey;
171 public function clear()