Open Journal Systems  3.3.0
lib/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php
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 
13 
17 class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Countable
18 {
19  private $name = 'attributes';
20 
24  private $storageKey;
25 
29  protected $attributes = array();
30 
36  public function __construct($storageKey = '_sf2_attributes')
37  {
38  $this->storageKey = $storageKey;
39  }
40 
44  public function getName()
45  {
46  return $this->name;
47  }
48 
49  public function setName($name)
50  {
51  $this->name = $name;
52  }
53 
57  public function initialize(array &$attributes)
58  {
59  $this->attributes = &$attributes;
60  }
61 
65  public function getStorageKey()
66  {
67  return $this->storageKey;
68  }
69 
73  public function has($name)
74  {
75  return array_key_exists($name, $this->attributes);
76  }
77 
81  public function get($name, $default = null)
82  {
83  return array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default;
84  }
85 
89  public function set($name, $value)
90  {
91  $this->attributes[$name] = $value;
92  }
93 
97  public function all()
98  {
99  return $this->attributes;
100  }
101 
105  public function replace(array $attributes)
106  {
107  $this->attributes = array();
108  foreach ($attributes as $key => $value) {
109  $this->set($key, $value);
110  }
111  }
112 
116  public function remove($name)
117  {
118  $retval = null;
119  if (array_key_exists($name, $this->attributes)) {
120  $retval = $this->attributes[$name];
121  unset($this->attributes[$name]);
122  }
123 
124  return $retval;
125  }
126 
130  public function clear()
131  {
132  $return = $this->attributes;
133  $this->attributes = array();
134 
135  return $return;
136  }
137 
143  public function getIterator()
144  {
145  return new \ArrayIterator($this->attributes);
146  }
147 
153  public function count()
154  {
155  return count($this->attributes);
156  }
157 }
Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag\count
count()
Definition: lib/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php:159
Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag\getStorageKey
getStorageKey()
Definition: lib/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php:71
Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag\has
has($name)
Definition: lib/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php:79
Symfony\Component\HttpFoundation\Session\Attribute
Definition: lib/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php:12
Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag\all
all()
Definition: lib/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php:103
Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag\replace
replace(array $attributes)
Definition: lib/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php:111
Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag\__construct
__construct($storageKey='_sf2_attributes')
Definition: lib/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php:42
Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag\setName
setName($name)
Definition: lib/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php:55
Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag\$attributes
$attributes
Definition: lib/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php:35
Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag\clear
clear()
Definition: lib/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php:136
Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag\initialize
initialize(array &$attributes)
Definition: lib/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php:63
Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag\getIterator
getIterator()
Definition: lib/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php:149
Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag
Definition: lib/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php:17
Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag\getName
getName()
Definition: lib/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php:50
Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface
Definition: lib/vendor/symfony/http-foundation/Session/Attribute/AttributeBagInterface.php:21