Zend Framework  3.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
AbstractContainer Class Reference

Session storage container. More...

Public Member Functions

 __construct ($name= 'Default', Manager $manager=null)
 Constructor.
 
 getName ()
 Get container name.
 
 getManager ()
 Get manager instance.
 
 offsetSet ($key, $value)
 Store a value within the container.
 
 offsetExists ($key)
 Determine if the key exists.
 
 offsetGet ($key)
 Retrieve a specific key in the container.
 
 offsetUnset ($key)
 Unset a single key in the container.
 
 exchangeArray ($input)
 Exchange the current array with another array or object.
 
 getIterator ()
 Iterate over session container.
 
 setExpirationSeconds ($ttl, $vars=null)
 Set expiration TTL.
 
 setExpirationHops ($hops, $vars=null)
 Set expiration hops for the container, a single key, or set of keys.
 
 getArrayCopy ()
 Creates a copy of the specific container name.
 
- Public Member Functions inherited from ArrayObject
 __construct ($input=[], $flags=self::STD_PROP_LIST, $iteratorClass= 'ArrayIterator')
 Constructor.
 
 __isset ($key)
 Returns whether the requested key exists.
 
 __set ($key, $value)
 Sets the value at the specified key to value.
 
 __unset ($key)
 Unsets the value at the specified key.
 
__get ($key)
 Returns the value at the specified key by reference.
 
 append ($value)
 Appends the value.
 
 asort ()
 Sort the entries by value.
 
 count ()
 Get the number of public properties in the ArrayObject.
 
 exchangeArray ($data)
 Exchange the array for another one.
 
 getArrayCopy ()
 Creates a copy of the ArrayObject.
 
 getFlags ()
 Gets the behavior flags.
 
 getIterator ()
 Create a new iterator from an ArrayObject instance.
 
 getIteratorClass ()
 Gets the iterator classname for the ArrayObject.
 
 ksort ()
 Sort the entries by key.
 
 natcasesort ()
 Sort an array using a case insensitive "natural order" algorithm.
 
 natsort ()
 Sort entries using a "natural order" algorithm.
 
 offsetExists ($key)
 Returns whether the requested key exists.
 
offsetGet ($key)
 Returns the value at the specified key.
 
 offsetSet ($key, $value)
 Sets the value at the specified key to value.
 
 offsetUnset ($key)
 Unsets the value at the specified key.
 
 serialize ()
 Serialize an ArrayObject.
 
 setFlags ($flags)
 Sets the behavior flags.
 
 setIteratorClass ($class)
 Sets the iterator classname for the ArrayObject.
 
 uasort ($function)
 Sort the entries with a user-defined comparison function and maintain key association.
 
 uksort ($function)
 Sort the entries by keys using a user-defined comparison function.
 
 unserialize ($data)
 Unserialize an ArrayObject.
 

Static Public Member Functions

static setDefaultManager (Manager $manager=null)
 Set the default ManagerInterface instance to use when none provided to constructor.
 
static getDefaultManager ()
 Get the default ManagerInterface instance.
 

Protected Member Functions

 setManager (Manager $manager=null)
 Set session manager.
 
 getStorage ()
 Get session storage object.
 
 createContainer ()
 Create a new container object on which to act.
 
 verifyNamespace ($createContainer=true)
 Verify container namespace.
 
 expireKeys ($key=null)
 Determine whether a given key needs to be expired.
 
 expireByExpiryTime (Storage $storage, $name, $key)
 Expire a key by expiry time.
 
 expireByHops (Storage $storage, $name, $key)
 Expire key by session hops.
 

Protected Attributes

 $name
 
 $manager
 
- Protected Attributes inherited from ArrayObject
 $storage
 
 $flag
 
 $iteratorClass
 
 $protectedProperties
 

Static Protected Attributes

static $managerDefaultClass = 'Zend\\Session\\SessionManager'
 
static $defaultManager
 

Additional Inherited Members

- Public Attributes inherited from ArrayObject
const STD_PROP_LIST = 1
 Properties of the object have their normal functionality when accessed as list (var_dump, foreach, etc.).
 
const ARRAY_AS_PROPS = 2
 Entries can be accessed as properties (read and write).
 

Detailed Description

Session storage container.

Allows for interacting with session storage in isolated containers, which may have their own expiries, or even expiries per key in the container. Additionally, expiries may be absolute TTLs or measured in "hops", which are based on how many times the key or container were accessed.

Constructor & Destructor Documentation

__construct (   $name = 'Default',
Manager  $manager = null 
)

Constructor.

Provide a name ('Default' if none provided) and a ManagerInterface instance.

Parameters
null | string$name
Manager$manager
Exceptions
Exception\InvalidArgumentException

Member Function Documentation

createContainer ( )
protected

Create a new container object on which to act.

Returns
ArrayObject
exchangeArray (   $input)

Exchange the current array with another array or object.

Parameters
array | object$input
Returns
array Returns the old array
See Also
ArrayObject::exchangeArray()
expireByExpiryTime ( Storage  $storage,
  $name,
  $key 
)
protected

Expire a key by expiry time.

Checks to see if the entire container has expired based on TTL setting, or the individual key.

Parameters
Storage$storage
string$nameContainer name
string$keyKey in container to check
Returns
bool
expireByHops ( Storage  $storage,
  $name,
  $key 
)
protected

Expire key by session hops.

Determines whether the container or an individual key within it has expired based on session hops

Parameters
Storage$storage
string$name
string$key
Returns
bool
expireKeys (   $key = null)
protected

Determine whether a given key needs to be expired.

Returns true if the key has expired, false otherwise.

Parameters
null | string$key
Returns
bool
getArrayCopy ( )

Creates a copy of the specific container name.

Returns
array
static getDefaultManager ( )
static

Get the default ManagerInterface instance.

If none provided, instantiates one of type $managerDefaultClass

Returns
Manager
Exceptions
Exception\InvalidArgumentExceptionif invalid manager default class provided
getIterator ( )

Iterate over session container.

Returns
Iterator
getManager ( )

Get manager instance.

Returns
Manager
getName ( )

Get container name.

Returns
string
getStorage ( )
protected

Get session storage object.

Proxies to ManagerInterface::getStorage()

Returns
Storage
offsetExists (   $key)

Determine if the key exists.

Parameters
string$key
Returns
bool
offsetGet (   $key)

Retrieve a specific key in the container.

Parameters
string$key
Returns
mixed
offsetSet (   $key,
  $value 
)

Store a value within the container.

Parameters
string$key
mixed$value
Returns
void
offsetUnset (   $key)

Unset a single key in the container.

Parameters
string$key
Returns
void
static setDefaultManager ( Manager  $manager = null)
static

Set the default ManagerInterface instance to use when none provided to constructor.

Parameters
Manager$manager
Returns
void
setExpirationHops (   $hops,
  $vars = null 
)

Set expiration hops for the container, a single key, or set of keys.

Parameters
int$hops
null | string | array$vars
Exceptions
Exception\InvalidArgumentException
Returns
Container
setExpirationSeconds (   $ttl,
  $vars = null 
)

Set expiration TTL.

Set the TTL for the entire container, a single key, or a set of keys.

Parameters
int$ttlTTL in seconds
string | array | null$vars
Returns
Container
Exceptions
Exception\InvalidArgumentException
setManager ( Manager  $manager = null)
protected

Set session manager.

Parameters
null | Manager$manager
Returns
Container
Exceptions
Exception\InvalidArgumentException
verifyNamespace (   $createContainer = true)
protected

Verify container namespace.

Checks to see if a container exists within the Storage object already. If not, one is created; if so, checks to see if it's an ArrayObject. If not, it raises an exception; otherwise, it returns the Storage object.

Parameters
bool$createContainerWhether or not to create the container for the namespace
Returns
Storage|null Returns null only if $createContainer is false
Exceptions
Exception\RuntimeException

Member Data Documentation

$defaultManager
staticprotected
$manager
protected
$managerDefaultClass = 'Zend\\Session\\SessionManager'
staticprotected
$name
protected