PVSession is the class for handling the cookie session information related to the system.
The class offers a variety of tools for how to set up basic session control within your application. These features can be used in conjunction with other session handling methodologies.
Example:
//Initialize the class
PVSession::init();
//Write data to a cookie
PVSession::writeCookie('foo', 'bar');
echo PVSession::readCookie('foo');
//Encrypt the value
PVSession::writeCookie('foo', 'bar', array('hash_cookie' => true));
echo PVSession::readCookie('foo', array('hash_cookie' => true);
| package |
system |
|---|
__callStatic(string $method, mixed $args = array()) : mixed
| access |
public |
|---|
stringThe key/name assigned to the method when added
mixedArguements to pass to the annoymous function. The function is called using call_user_func_array.
mixed$value The value returned is the value the stored function returns
_applyFilter(string $class, string $method, mixed $data, array $options = array()) : mixed
| access |
protected |
|---|
stringThe name of the class the filter is in
stringThe method the filter is in
mixedThe data that is being passed to the filter
arrayoptions to be passed to the filter. Passed options we be passed to the function. -'default_return' mixed: If no filter is return, the data passed in by default will be return. Can be overriden -'event' string: An event to associate with the filter. Default is null
mixed$data The data the function returns
_callAdapter(string $class, string $method) : mixed
| access |
protected |
|---|
stringThe name of the class the adapter is in
stringTHe name of the method the class is being called from.
mixed$value A value that the adapter returns
_hasAdapter( $class, string $method) : \boolea
| access |
protected |
|---|
stringThe associated method
\boolea$hasAdapter Returns true if it has an adapter or false if it doesn not
_hasFilter(string $class, string $method)
stringThe class the filter is in
stringThe method of the class that the filter is in
_invokeMethod(string $class, string $method, array $args) : mixed
| access |
protected |
|---|
stringThe name of the class to be called
stringThe name of the method in the class to be called
arrayAn array of arguements. Arguements have to be embedded in an array to be called.
mixed$data Data returned by the function called
_invokeStaticMethod(string $class, string $method, array $args) : mixed
| access |
protected |
|---|
stringThe name of the class to be called
stringThe name of the method in the class to be called
arrayAn array of arguements. Arguements have to be embedded in an array to be called.
mixed$data Data returned by the function called
_logAdapter(array $data) : void
| access |
private |
|---|
arrayThe data in the adapter
_logFilter(array $data) : void
| access |
private |
|---|
arrayThe data in the filter
_logObserver(array $data) : void
| access |
private |
|---|
arrayThe data in the observer
_notify(string $event) : void
| access |
protected |
|---|
stringThe name of the even that occured that will trigger notifies
_prepareLogData(array $data) : string
| access |
private |
|---|
array
string$message JSON encode message of information about the data
addAdapter(string $trigger_class, string $trigger_method, string $call_class, array $options = array()) : void
| access |
public |
|---|---|
| todo |
add ability to adapt singleton class |
stringThe class that contains the function the adapter will respond too
stringThe method called that will have the adapter to be called.
stringThe new class to be called that has the same method name
arrayAn array of options that be called -'object' string : Assumes that default method in the class to be called is static. If called object needs to be instantiated, change to object to 'instance' and one will be created before the adapter calls the function -'call_method' string: By default the method to be called to override the current one should be the same name. But this can be ovveridden to call a different method. -'type' string: The type of method being called. Default is class_method but if the method is a closure, set the type to be 'closure' and make the $trigger_method the closure
addClassAdapter(mixed $trigger_class, string $call_class, array $options = array()) : void
| access |
public |
|---|---|
| todo |
Add ability to use singleton classes |
mixedThis can either be the name of the class or an object whose methods will be adapted to another class. The class should be included or be autoloaded by this point.
stringThe call class is the classes methods that will be called in place of the methods in the trigger_class. These class does not have to be included as this point.
arrayOptions that be used to further distinguish the behavior of the adapters added -'object' string: Determines if the object being adapted to is static or an instance.Default is static -'call_class' string: The name of the class that the methods will be adapted too. -'class' string: The name of the whose methods will be adapted to another class
addFilter(string $class, string $method, string $filter_class, string $filter_method, array $options = array()) : void
| access |
public |
|---|
stringThe name of the class the filter is going in
stringThe name of the method the filter is in
stringThe class that the filter resides in.
stringThe method in the class that the parameters will be passed too.
arrayOptions that can be set for further modifying the filter. -'object' string: If the method being called is static, static should be inserted. If its in an instance, 'instance' should be set. Default is set to static. -'event' string: Associate this filter with an event. -'type' string: The type of function being called. Default is class_method but if the function is a closure, set the type to be 'closure' and make the $filter_method the closure
addMethod(string $method, \function $closure) : void
| access |
public |
|---|
stringThe key/value that will be used to call the function
\functionThe anonymous function/closure to be added
addObserver(string $event, string $class, string $method, array $options = array()) : void
| access |
public |
|---|
stringThe name of the event that will cause a certain class and method to fire
stringThe name of the class that contains the function that will be fired for this event
stringThe name of the method that will be fired when the event occurs
arrayOptions to further the define the firing of an event -'object' string : If the method being called is static, should be set to static. Else set to instance -'class' stinrg : The name of the class to be called. Default is the class that is passed in. -'method' string: The name of the method to be called. Default is the method that is passed in. -'type' string: The type of function being called. Default is class_method but if the function is a closure, set the type to be 'closure' and make the $method the closure
addToCollection(mixed $data) : void
| access |
public |
|---|
mixedAny data type( Object, Array, int, etc) to add to the public data collection
addToCollectionWithName(string $name, mixed $data) : void
| access |
public |
|---|---|
| todo |
check the relevance of get and set |
stringThe key/index to assign the value to
mixedData to be stored in the collection
clearFilters(string $class, string $method) : void
| access |
public |
|---|
stringThe class the filter is in
stringThe method of the class that the filter is in
clearObservers(string $event) : void
| access |
public |
|---|
stringThe event to remove all the observers from
deleteCookie(string $name, array $options = array())
stringThe name/key of the current cookie
arrayOptions than can be defined to customize the cookie deletion process -'hash_session' _boolean: If the cookie is hashed, use this to delete it. -'cookie_path' string: The path where the cookie is to be stored -'cookie_domain' string: The domain the that the cookie resides on -'cookie_secure' boolean: -'cookie_httponly' boolean:
deleteSession(string $name, array $options = array()) : void
| access |
public |
|---|
stringKey for the session
arrayOptions used for deleting the key -'hash_session' _boolean: Hash a session so its value is not easily readable
get(string $index) : mixed
| access |
public |
|---|
stringThe index to retrieve a value from
mixed$data The data that was stored at that index
getCookieDefaults() : array
| access |
private |
|---|---|
arraydefault_cookie_options
getInstance() : object
| access |
public |
|---|---|
object$instance Returns the instance of a class.
getIterator() : \PVIterator
getSessionDefaults() : array
| access |
private |
|---|---|
arraydefault_session_options
init(array $session_vars = array()) : void
arrayAn array of values that set how the class functions. -'cookie_path' string: The path where the cookie is to be stored -'cookie_domain' string: The domain the that the cookie resides on -'cookie_secure' boolean: Access the cookie only over an secure connection -'cookie_httponly' boolean: Write to the cookie only over an http(s) connection -'cookie_lifetime' int: The amount of time the cookie is active for -'hash_cookie' boolean :Hash the cookie to its value is not easily readable -'hash_session' _boolean: Has a season so its value is not easily readable -'session_name' string : Name of the current session -'session_lifetime' int: The life time of the session, in seconds -'session_path' string: The path of the session. -'session_domain' string: The domain of the session. Default is current. -'session_secure'boolean: Access the session only over a secure connection -'session_httponly' _boolean: Writes to the session only over an http connection
readCookie(string $name, array $options = array()) : mixed
| access |
public |
|---|
stringThe key the cookie was saved as
arrayOptions thats configure reading the cookie -hash_cookie boolean: If the cookie was hashed, set the value to true
mixed$value The value retrieved from the cookie. Arrays and objects serialized will be unseralized and returned.
readSession(string $name, array $options = array()) : mixed
| access |
public |
|---|
stringThe key to access the session variable
arrayOptions to define how the information is acccessed -'hash_session' _boolean: Hash a session so its value is not easily readable
mixed$stored_value
removeAdapter( $class, string $method) : void
| access |
public |
|---|
stringThe associated method
removeClassAdapter( $class) : void
| access |
public |
|---|
set(string $index, mixed $value) : void
| access |
public |
|---|
stringThe key or index to store the value at
mixedA mixed value that can be anytype
setAdapterTrace(boolean $trace = false) : void
| access |
public |
|---|
booleanDefault is false. If set to true, will trace adatper.
setFilterTrace(boolean $trace = false) : void
| access |
public |
|---|
booleanDefault is false. If set to true, will trace filter.
setObserverTrace(boolean $trace = false) : void
| access |
public |
|---|
booleanDefault is false. If set to true, will trace observer.
writeCookie(string $name, string $value, array $options = array()) : void
stringKey for the value to be written as a cookie
stringThe value to be stored in a cookie.
arrayOptions that can change how the cookie is stored. The options passed will override the default options passed in the init -'cookie_path' string: The path where the cookie is to be stored -'cookie_domain' string: The domain the that the cookie resides on -'cookie_secure' boolean: If the cookie is only writable over a secure connection -'cookie_httponly' boolean: If the cookie is only accesible over an http connection -'cookie_lifetime' int: The amount of time the cookie is active for in seconds -'hash_cookie' boolean :Hash the cookie key and its value is not easily readable
writeSession(string $name, $value, $options = array()) : void
| access |
public |
|---|
stringThe key for the session
session_lifetime :
session_path :
session_domain :
session_secure :
session_httponly :
hash_session :
_collection :
_methods :
_adapters :
_observers :
_instances :
_filters :
_traceAdapters :
_traceFilters :
_traceObservers :