\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

$name

$name

$storageKey

$storageKey

$namespaceCharacter

$namespaceCharacter

Methods

__construct()

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

Parameters

string $storageKey

Session storage key

string $namespaceCharacter

Namespace character to use in keys

Returns

mixed —

getName()

getName() : mixed

{@inheritdoc}

Returns

mixed —

setName()

setName(string  $name) : mixed

Parameters

string $name

Returns

mixed —

initialize()

initialize(array  $attributes) : mixed

{@inheritdoc}

Parameters

array $attributes

Returns

mixed —

getStorageKey()

getStorageKey() : mixed

{@inheritdoc}

Returns

mixed —

has()

has(string  $name) : bool

Checks if an attribute is defined.

Parameters

string $name

Returns

bool —

get()

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

Returns an attribute.

Parameters

string $name
mixed $default

The default value if not found

Returns

mixed —

set()

set(string  $name, mixed  $value) : mixed

Sets an attribute.

Parameters

string $name
mixed $value

Returns

mixed —

all()

all() : array<string,mixed>

Returns attributes.

Returns

array

replace()

replace(array  $attributes) : mixed

Parameters

array $attributes

Returns

mixed —

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() : mixed

{@inheritdoc}

Returns

mixed —

getIterator()

getIterator() : \ArrayIterator<string,mixed>

Returns an iterator for attributes.

Returns

\ArrayIterator

count()

count() : int

Returns the number of attributes.

Returns

int —

resolveAttributePath()

& resolveAttributePath(string  $name, bool  $writeContext = false) : array|null

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

bool $writeContext

Write context, default false

Returns

array|null —

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 —