NamespacedAttributeBag
extends AttributeBag
in package
This class provides structured storage of session attributes using a name spacing character in the key.
Tags
Table of Contents
- $attributes : mixed
- $name : mixed
- $namespaceCharacter : mixed
- $storageKey : mixed
- __construct() : mixed
- all() : array<string, mixed>
- Returns attributes.
- clear() : mixed
- {@inheritdoc}
- count() : int
- Returns the number of attributes.
- get() : mixed
- Returns an attribute.
- getIterator() : ArrayIterator<string, mixed>
- Returns an iterator for attributes.
- getName() : mixed
- {@inheritdoc}
- getStorageKey() : mixed
- {@inheritdoc}
- has() : bool
- Checks if an attribute is defined.
- initialize() : mixed
- {@inheritdoc}
- remove() : mixed
- Removes an attribute.
- replace() : mixed
- set() : mixed
- Sets an attribute.
- setName() : mixed
- resolveAttributePath() : array<string|int, mixed>|null
- Resolves a path in attributes property and returns it as a reference.
- resolveKey() : string
- Resolves the key from the name.
Properties
$attributes
protected
mixed
$attributes
= []
$name
private
mixed
$name
= 'attributes'
$namespaceCharacter
private
mixed
$namespaceCharacter
$storageKey
private
mixed
$storageKey
Methods
__construct()
public
__construct([string $storageKey = '_sf2_attributes' ][, string $namespaceCharacter = '/' ]) : mixed
Parameters
- $storageKey : string = '_sf2_attributes'
-
Session storage key
- $namespaceCharacter : string = '/'
-
Namespace character to use in keys
Return values
mixed —all()
Returns attributes.
public
all() : array<string, mixed>
Return values
array<string, mixed> —clear()
{@inheritdoc}
public
clear() : mixed
Return values
mixed —count()
Returns the number of attributes.
public
count() : int
Return values
int —get()
Returns an attribute.
public
get(string $name[, mixed $default = null ]) : mixed
Parameters
- $name : string
- $default : mixed = null
-
The default value if not found
Return values
mixed —getIterator()
Returns an iterator for attributes.
public
getIterator() : ArrayIterator<string, mixed>
Return values
ArrayIterator<string, mixed> —getName()
{@inheritdoc}
public
getName() : mixed
Return values
mixed —getStorageKey()
{@inheritdoc}
public
getStorageKey() : mixed
Return values
mixed —has()
Checks if an attribute is defined.
public
has(string $name) : bool
Parameters
- $name : string
Return values
bool —initialize()
{@inheritdoc}
public
initialize(array<string|int, mixed> &$attributes) : mixed
Parameters
- $attributes : array<string|int, mixed>
Return values
mixed —remove()
Removes an attribute.
public
remove(string $name) : mixed
Parameters
- $name : string
Return values
mixed —The removed value or null when it does not exist
replace()
public
replace(array<string|int, mixed> $attributes) : mixed
Parameters
- $attributes : array<string|int, mixed>
Return values
mixed —set()
Sets an attribute.
public
set(string $name, mixed $value) : mixed
Parameters
- $name : string
- $value : mixed
Return values
mixed —setName()
public
setName(string $name) : mixed
Parameters
- $name : string
Return values
mixed —resolveAttributePath()
Resolves a path in attributes property and returns it as a reference.
protected
resolveAttributePath(string $name[, bool $writeContext = false ]) : array<string|int, mixed>|null
This method allows structured namespacing of session attributes.
Parameters
- $name : string
-
Key name
- $writeContext : bool = false
-
Write context, default false
Return values
array<string|int, mixed>|null —resolveKey()
Resolves the key from the name.
protected
resolveKey(string $name) : string
This is the last part in a dot separated string.
Parameters
- $name : string