[ Index ] |
PHP Cross Reference of phpBB-3.2.11-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 * AutoExpireFlashBag flash message container. 16 * 17 * @author Drak <drak@zikula.org> 18 */ 19 class AutoExpireFlashBag implements FlashBagInterface 20 { 21 private $name = 'flashes'; 22 private $flashes = array('display' => array(), 'new' => array()); 23 private $storageKey; 24 25 /** 26 * @param string $storageKey The key used to store flashes in the session 27 */ 28 public function __construct($storageKey = '_sf2_flashes') 29 { 30 $this->storageKey = $storageKey; 31 } 32 33 /** 34 * {@inheritdoc} 35 */ 36 public function getName() 37 { 38 return $this->name; 39 } 40 41 public function setName($name) 42 { 43 $this->name = $name; 44 } 45 46 /** 47 * {@inheritdoc} 48 */ 49 public function initialize(array &$flashes) 50 { 51 $this->flashes = &$flashes; 52 53 // The logic: messages from the last request will be stored in new, so we move them to previous 54 // This request we will show what is in 'display'. What is placed into 'new' this time round will 55 // be moved to display next time round. 56 $this->flashes['display'] = array_key_exists('new', $this->flashes) ? $this->flashes['new'] : array(); 57 $this->flashes['new'] = array(); 58 } 59 60 /** 61 * {@inheritdoc} 62 */ 63 public function add($type, $message) 64 { 65 $this->flashes['new'][$type][] = $message; 66 } 67 68 /** 69 * {@inheritdoc} 70 */ 71 public function peek($type, array $default = array()) 72 { 73 return $this->has($type) ? $this->flashes['display'][$type] : $default; 74 } 75 76 /** 77 * {@inheritdoc} 78 */ 79 public function peekAll() 80 { 81 return array_key_exists('display', $this->flashes) ? (array) $this->flashes['display'] : array(); 82 } 83 84 /** 85 * {@inheritdoc} 86 */ 87 public function get($type, array $default = array()) 88 { 89 $return = $default; 90 91 if (!$this->has($type)) { 92 return $return; 93 } 94 95 if (isset($this->flashes['display'][$type])) { 96 $return = $this->flashes['display'][$type]; 97 unset($this->flashes['display'][$type]); 98 } 99 100 return $return; 101 } 102 103 /** 104 * {@inheritdoc} 105 */ 106 public function all() 107 { 108 $return = $this->flashes['display']; 109 $this->flashes['display'] = array(); 110 111 return $return; 112 } 113 114 /** 115 * {@inheritdoc} 116 */ 117 public function setAll(array $messages) 118 { 119 $this->flashes['new'] = $messages; 120 } 121 122 /** 123 * {@inheritdoc} 124 */ 125 public function set($type, $messages) 126 { 127 $this->flashes['new'][$type] = (array) $messages; 128 } 129 130 /** 131 * {@inheritdoc} 132 */ 133 public function has($type) 134 { 135 return array_key_exists($type, $this->flashes['display']) && $this->flashes['display'][$type]; 136 } 137 138 /** 139 * {@inheritdoc} 140 */ 141 public function keys() 142 { 143 return array_keys($this->flashes['display']); 144 } 145 146 /** 147 * {@inheritdoc} 148 */ 149 public function getStorageKey() 150 { 151 return $this->storageKey; 152 } 153 154 /** 155 * {@inheritdoc} 156 */ 157 public function clear() 158 { 159 return $this->all(); 160 } 161 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |