17 class AttributeBag
implements AttributeBagInterface, \IteratorAggregate, \Countable
19 private $name =
'attributes';
27 public function __construct(
string $storageKey =
'_sf2_attributes')
29 $this->storageKey = $storageKey;
58 return $this->storageKey;
64 public function has($name)
66 return \array_key_exists($name, $this->attributes);
72 public function get($name, $default =
null)
74 return \array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default;
80 public function set($name, $value)
82 $this->attributes[$name] = $value;
98 $this->attributes = [];
100 $this->
set($key, $value);
107 public function remove($name)
110 if (\array_key_exists($name, $this->attributes)) {
111 $retval = $this->attributes[$name];
112 unset($this->attributes[$name]);
124 $this->attributes = [];
136 return new \ArrayIterator($this->attributes);
146 return \count($this->attributes);