1 | <?php |
||
19 | class AttributeBag implements AttributeBagInterface |
||
20 | { |
||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $name = 'attributes'; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | private $storageKey; |
||
30 | |||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | private $attributes = array(); |
||
35 | |||
36 | /** |
||
37 | * Constructor. |
||
38 | * |
||
39 | * @param string $storageKey |
||
40 | */ |
||
41 | public function __construct($storageKey = '__BOROBUDUR_ATTRIBUTES', $name = null) |
||
48 | |||
49 | /** |
||
50 | * Clear attributes and replace with sets of it. |
||
51 | * |
||
52 | * @param array $attributes |
||
53 | * |
||
54 | * @return $this |
||
55 | */ |
||
56 | public function replace(array $attributes) |
||
62 | |||
63 | /** |
||
64 | * Add sets of attribute. |
||
65 | * |
||
66 | * @param array $attributes |
||
67 | * |
||
68 | * @return $this |
||
69 | */ |
||
70 | public function add(array $attributes) |
||
78 | |||
79 | /** |
||
80 | * Set attribute. |
||
81 | * |
||
82 | * @param string $key |
||
83 | * @param mixed $value |
||
84 | * |
||
85 | * @return $this |
||
86 | */ |
||
87 | public function set($key, $value) |
||
93 | |||
94 | /** |
||
95 | * Get attribute value by key or return default value if not exist. |
||
96 | * |
||
97 | * @param string $key |
||
98 | * @param mixed|null $default |
||
99 | * |
||
100 | * @return mixed |
||
101 | */ |
||
102 | public function get($key, $default = null) |
||
110 | |||
111 | /** |
||
112 | * Check if attribute exist by key. |
||
113 | * |
||
114 | * @param string $key |
||
115 | * |
||
116 | * @return bool |
||
117 | */ |
||
118 | public function has($key) |
||
122 | |||
123 | /** |
||
124 | * Get all attributes. |
||
125 | * |
||
126 | * @return array |
||
127 | */ |
||
128 | public function all() |
||
132 | |||
133 | /** |
||
134 | * Remove attribute by key. |
||
135 | * |
||
136 | * @param string $key |
||
137 | * |
||
138 | * @return $this |
||
139 | */ |
||
140 | public function remove($key) |
||
148 | |||
149 | /** |
||
150 | * {@inheritdoc} |
||
151 | */ |
||
152 | public function getIterator() |
||
156 | |||
157 | /** |
||
158 | * {@inheritdoc} |
||
159 | */ |
||
160 | public function count() |
||
164 | |||
165 | /** |
||
166 | * Set attribute name. |
||
167 | * |
||
168 | * @param string $name |
||
169 | * |
||
170 | * @return $this |
||
171 | */ |
||
172 | public function setName($name) |
||
178 | |||
179 | /** |
||
180 | * Get session bag name. |
||
181 | * |
||
182 | * @return string |
||
183 | */ |
||
184 | public function getName() |
||
188 | |||
189 | /** |
||
190 | * Identity storage. |
||
191 | * |
||
192 | * @return string |
||
193 | */ |
||
194 | public function getStorageKey() |
||
198 | |||
199 | /** |
||
200 | * Initialize sessions. |
||
201 | * |
||
202 | * @param array $sessions |
||
203 | */ |
||
204 | public function initialize(array &$sessions) |
||
208 | |||
209 | /** |
||
210 | * Clear session and return all data. |
||
211 | * |
||
212 | * @return array |
||
213 | */ |
||
214 | public function clear() |
||
221 | } |
||
222 |