20 class NamespacedAttributeBag
extends AttributeBag
22 private $namespaceCharacter;
28 public function __construct(
string $storageKey =
'_sf2_attributes',
string $namespaceCharacter =
'/')
30 $this->namespaceCharacter = $namespaceCharacter;
31 parent::__construct($storageKey);
37 public function has($name)
53 public function get($name, $default =
null)
69 public function set($name, $value)
79 public function remove($name)
105 $name = (0 === strpos($name, $this->namespaceCharacter)) ? substr($name, 1) : $name;
112 $parts = explode($this->namespaceCharacter, $name);
113 if (\
count($parts) < 2) {
114 if (!$writeContext) {
118 $array[$parts[0]] = [];
123 unset($parts[\
count($parts) - 1]);
125 foreach ($parts as $part) {
126 if (
null !== $array && !\array_key_exists($part, $array)) {
127 if (!$writeContext) {
136 $array = &$array[$part];
153 if (
false !== $pos = strrpos($name, $this->namespaceCharacter)) {
154 $name = substr($name, $pos + 1);