protected function NamespacedAttributeBag::resolveAttributePath

Resolves a path in attributes property and returns it as a reference.

This method allows structured namespacing of session attributes.

Parameters

string $name Key name:

boolean $writeContext Write context, default false:

Return value

array

4 calls to NamespacedAttributeBag::resolveAttributePath()
NamespacedAttributeBag::get in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php
Returns an attribute.
NamespacedAttributeBag::has in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php
Checks if an attribute is defined.
NamespacedAttributeBag::remove in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php
Removes an attribute.
NamespacedAttributeBag::set in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php
Sets an attribute.

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php, line 107

Class

NamespacedAttributeBag
This class provides structured storage of session attributes using a name spacing character in the key.

Namespace

Symfony\Component\HttpFoundation\Session\Attribute

Code

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;
}