[ Index ] |
PHP Cross Reference of phpBB-3.1.12-deutsch |
[Summary view] [Print] [Text view]
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 12 namespace Symfony\Component\HttpFoundation\Session\Flash; 13 14 /** 15 * FlashBag flash message container. 16 * 17 * @author Drak <drak@zikula.org> 18 */ 19 class FlashBag implements FlashBagInterface, \IteratorAggregate 20 { 21 private $name = 'flashes'; 22 23 /** 24 * Flash messages. 25 * 26 * @var array 27 */ 28 private $flashes = array(); 29 30 /** 31 * The storage key for flashes in the session. 32 * 33 * @var string 34 */ 35 private $storageKey; 36 37 /** 38 * Constructor. 39 * 40 * @param string $storageKey The key used to store flashes in the session. 41 */ 42 public function __construct($storageKey = '_sf2_flashes') 43 { 44 $this->storageKey = $storageKey; 45 } 46 47 /** 48 * {@inheritdoc} 49 */ 50 public function getName() 51 { 52 return $this->name; 53 } 54 55 public function setName($name) 56 { 57 $this->name = $name; 58 } 59 60 /** 61 * {@inheritdoc} 62 */ 63 public function initialize(array &$flashes) 64 { 65 $this->flashes = &$flashes; 66 } 67 68 /** 69 * {@inheritdoc} 70 */ 71 public function add($type, $message) 72 { 73 $this->flashes[$type][] = $message; 74 } 75 76 /** 77 * {@inheritdoc} 78 */ 79 public function peek($type, array $default = array()) 80 { 81 return $this->has($type) ? $this->flashes[$type] : $default; 82 } 83 84 /** 85 * {@inheritdoc} 86 */ 87 public function peekAll() 88 { 89 return $this->flashes; 90 } 91 92 /** 93 * {@inheritdoc} 94 */ 95 public function get($type, array $default = array()) 96 { 97 if (!$this->has($type)) { 98 return $default; 99 } 100 101 $return = $this->flashes[$type]; 102 103 unset($this->flashes[$type]); 104 105 return $return; 106 } 107 108 /** 109 * {@inheritdoc} 110 */ 111 public function all() 112 { 113 $return = $this->peekAll(); 114 $this->flashes = array(); 115 116 return $return; 117 } 118 119 /** 120 * {@inheritdoc} 121 */ 122 public function set($type, $messages) 123 { 124 $this->flashes[$type] = (array) $messages; 125 } 126 127 /** 128 * {@inheritdoc} 129 */ 130 public function setAll(array $messages) 131 { 132 $this->flashes = $messages; 133 } 134 135 /** 136 * {@inheritdoc} 137 */ 138 public function has($type) 139 { 140 return array_key_exists($type, $this->flashes) && $this->flashes[$type]; 141 } 142 143 /** 144 * {@inheritdoc} 145 */ 146 public function keys() 147 { 148 return array_keys($this->flashes); 149 } 150 151 /** 152 * {@inheritdoc} 153 */ 154 public function getStorageKey() 155 { 156 return $this->storageKey; 157 } 158 159 /** 160 * {@inheritdoc} 161 */ 162 public function clear() 163 { 164 return $this->all(); 165 } 166 167 /** 168 * Returns an iterator for flashes. 169 * 170 * @return \ArrayIterator An \ArrayIterator instance 171 */ 172 public function getIterator() 173 { 174 return new \ArrayIterator($this->all()); 175 } 176 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |