W3cubDocs

/Symfony 3.0

Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag

class NamespacedAttributeBag extends AttributeBag

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

Methods

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

Constructor.

string getName()

Gets this bag's name.

from AttributeBag
setName($name) from AttributeBag
initialize(array $attributes)

Initializes the Bag.

from AttributeBag
string getStorageKey()

Gets the storage key for this bag.

from AttributeBag
bool has(string $name)

Checks if an attribute is defined.

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

Returns an attribute.

set(string $name, mixed $value)

Sets an attribute.

array all()

Returns attributes.

from AttributeBag
replace(array $attributes)

Sets attributes.

from AttributeBag
mixed remove(string $name)

Removes an attribute.

mixed clear()

Clears out data from bag.

from AttributeBag
ArrayIterator getIterator()

Returns an iterator for attributes.

from AttributeBag
int count()

Returns the number of attributes.

from AttributeBag

Details

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

Constructor.

Parameters

string $storageKey Session storage key.
string $namespaceCharacter Namespace character to use in keys.

public string getName()

Gets this bag's name.

Return Value

string

public setName($name)

Parameters

$name

public initialize(array $attributes)

Initializes the Bag.

Parameters

array $attributes

public string getStorageKey()

Gets the storage key for this bag.

Return Value

string

public bool has(string $name)

Checks if an attribute is defined.

Parameters

string $name The attribute name

Return Value

bool true if the attribute is defined, false otherwise

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

Returns an attribute.

Parameters

string $name The attribute name
mixed $default The default value if not found

Return Value

mixed

public set(string $name, mixed $value)

Sets an attribute.

Parameters

string $name
mixed $value

public array all()

Returns attributes.

Return Value

array Attributes

public replace(array $attributes)

Sets attributes.

Parameters

array $attributes Attributes

public mixed remove(string $name)

Removes an attribute.

Parameters

string $name

Return Value

mixed The removed value or null when it does not exist

public mixed clear()

Clears out data from bag.

Return Value

mixed Whatever data was contained.

public ArrayIterator getIterator()

Returns an iterator for attributes.

Return Value

ArrayIterator An \ArrayIterator instance

public int count()

Returns the number of attributes.

Return Value

int The number of attributes