\Symfony\Component\HttpFoundation\Session\AttributeNamespacedAttributeBag

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

Summary

Methods
Properties
Constants
__construct()
getName()
setName()
initialize()
getStorageKey()
has()
get()
set()
all()
replace()
remove()
clear()
getIterator()
count()
No public properties found
No constants found
resolveAttributePath()
resolveKey()
$attributes
N/A
No private methods found
$name
$storageKey
$namespaceCharacter
N/A

Properties

$attributes

$attributes : 

Type

$name

$name : 

Type

$storageKey

$storageKey : 

Type

$namespaceCharacter

$namespaceCharacter : 

Type

Methods

__construct()

__construct(string  $storageKey = '_sf2_attributes', string  $namespaceCharacter = '/') 

Parameters

string $storageKey

Session storage key

string $namespaceCharacter

Namespace character to use in keys

getName()

getName() 

{@inheritdoc}

setName()

setName(  $name) 

Parameters

$name

initialize()

initialize(array  $attributes) 

{@inheritdoc}

Parameters

array $attributes

getStorageKey()

getStorageKey() 

{@inheritdoc}

has()

has(string  $name) : boolean

Checks if an attribute is defined.

Parameters

string $name

The attribute name

Returns

boolean —

true if the attribute is defined, false otherwise

get()

get(string  $name, mixed  $default = null) : mixed

Returns an attribute.

Parameters

string $name

The attribute name

mixed $default

The default value if not found

Returns

mixed

set()

set(string  $name, mixed  $value) 

Sets an attribute.

Parameters

string $name
mixed $value

all()

all() : array

Returns attributes.

Returns

array —

Attributes

replace()

replace(array  $attributes) 

Sets attributes.

Parameters

array $attributes

Attributes

remove()

remove(string  $name) : mixed

Removes an attribute.

Parameters

string $name

Returns

mixed —

The removed value or null when it does not exist

clear()

clear() 

{@inheritdoc}

getIterator()

getIterator() : \ArrayIterator

Returns an iterator for attributes.

Returns

\ArrayIterator —

An \ArrayIterator instance

count()

count() : integer

Returns the number of attributes.

Returns

integer —

The number of attributes

resolveAttributePath()

resolveAttributePath(string  $name, boolean  $writeContext = false) : array

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

Returns

array

resolveKey()

resolveKey(string  $name) : string

Resolves the key from the name.

This is the last part in a dot separated string.

Parameters

string $name

Returns

string