Resolves a path in attributes property and returns it as a reference.
This method allows structured namespacing of session attributes.
string $name Key name:
boolean $writeContext Write context, default false:
array
protected function &resolveAttributePath($name, $writeContext = false) {
$array =& $this->attributes;
$name = strpos($name, $this->namespaceCharacter) === 0 ? substr($name, 1) : $name;
// Check if there is anything to do, else return
if (!$name) {
return $array;
}
$parts = explode($this->namespaceCharacter, $name);
if (count($parts) < 2) {
if (!$writeContext) {
return $array;
}
$array[$parts[0]] = array();
return $array;
}
unset($parts[count($parts) - 1]);
foreach ($parts as $part) {
if (null !== $array && !array_key_exists($part, $array)) {
$array[$part] = $writeContext ? array() : null;
}
$array =& $array[$part];
}
return $array;
}