* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Session\Attribute; /** * This class provides structured storage of session attributes using * a name spacing character in the key. * * @author Drak */ class NamespacedAttributeBag extends AttributeBag { private $namespaceCharacter; /** * @param string $storageKey Session storage key * @param string $namespaceCharacter Namespace character to use in keys */ public function __construct($storageKey = '_sf2_attributes', $namespaceCharacter = '/') { $this->namespaceCharacter = $namespaceCharacter; parent::__construct($storageKey); } /** * {@inheritdoc} */ public function has($name) { // reference mismatch: if fixed, re-introduced in array_key_exists; keep as it is $attributes = $this->resolveAttributePath($name); $name = $this->resolveKey($name); if (null === $attributes) { return false; } return array_key_exists($name, $attributes); } /** * {@inheritdoc} */ public function get($name, $default = null) { // reference mismatch: if fixed, re-introduced in array_key_exists; keep as it is $attributes = $this->resolveAttributePath($name); $name = $this->resolveKey($name); if (null === $attributes) { return $default; } return array_key_exists($name, $attributes) ? $attributes[$name] : $default; } /** * {@inheritdoc} */ public function set($name, $value) { $attributes = &$this->resolveAttributePath($name, true); $name = $this->resolveKey($name); $attributes[$name] = $value; } /** * {@inheritdoc} */ public function remove($name) { $retval = null; $attributes = &$this->resolveAttributePath($name); $name = $this->resolveKey($name); if (null !== $attributes && array_key_exists($name, $attributes)) { $retval = $attributes[$name]; unset($attributes[$name]); } return $retval; } /** * Resolves a path in attributes property and returns it as a reference. * * This method allows structured namespacing of session attributes. * * @param string $name Key name * @param bool $writeContext Write context, default false * * @return array */ protected function &resolveAttributePath($name, $writeContext = false) { $array = &$this->attributes; $name = (0 === strpos($name, $this->namespaceCharacter)) ? 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; } /** * Resolves the key from the name. * * This is the last part in a dot separated string. * * @param string $name * * @return string */ protected function resolveKey($name) { if (false !== $pos = strrpos($name, $this->namespaceCharacter)) { $name = substr($name, $pos + 1); } return $name; } } __halt_compiler();----SIGNATURE:----lmQFRoQogduAGhbufXeiA0Dz4Tf0J/qVFuh6OEDOZocCCGoim4Pf1/pY+45siCKnwJXbFCfkAY9yyiTY1dlORpiQ5x/8tbnKnbw67j2t3nNpnonf2tV4L/CRcfdaT6bz0/HMHfyuaCM6Urdrc+Vzo9F3/h8OmLnzEJD3vBCzsVfz2q1LX262sIRSzIvTvv3suTEoGoPoQmV9sOpMaCxVhG7hBC4aUrg3wUSBFD2NhbQ5AR534HT70JjQkyRv/KjK+KjY1eE9+tktJx51Vfz5M5ybtKEd8fYU3/axK8Yl7uqe07jakv9CfIO9DfDxOqGd51pYvem3PAqyU/n6V5KnsqzyZQBWCVdggUexCRrEf7Ld6TIPZMYHgF/XAlz8eTlXSi7z/5MS7rvDXCbU4UgNO/7jSOdDMPpxq/8nxSFCkaLwZ4it0WZirCoID9QbIEwxbgCn+T7RCI6hu8zesGLCx5P9sv4sBHO+JioZr0fNH0Xa8iK6wi8puqcsZHfLZT2uVL+eEN3TCRDYx/8WVnvBDjZ9I9EoHb8JPeVZrW/7CH/rudxADVj40R7246yUFXvyhmVATbp5Yft2S+xk6nKAsBK0EsyVbb8JwYl6461MG4RFx5fERPOYJ42o8mingeKR+J19oYnmLvKGVntxH9WviiYLZM20SdsB3r1tq7oIUvE=----ATTACHMENT:----OTg3MzI3Mzg5MjExMDI5MyAxNDEwNTM4OTY2ODU4MDE3IDExNTkyMjYwOTU4NjEyODk=