aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/ElggSession.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-10-28 19:17:36 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-10-28 19:17:36 +0000
commit7ddd9521b3f3a397da3b0a6b56238d31414eb4be (patch)
tree6eb6a9a51db5fa0f5d3cc2ec6de29b9e258b12a1 /engine/classes/ElggSession.php
parentbd3484417d170e62bc94e9db81d4ad37e8ddee6a (diff)
downloadelgg-7ddd9521b3f3a397da3b0a6b56238d31414eb4be.tar.gz
elgg-7ddd9521b3f3a397da3b0a6b56238d31414eb4be.tar.bz2
Standardized code in all of core, not including language files, tests, or core mods.
git-svn-id: http://code.elgg.org/elgg/trunk@7124 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/classes/ElggSession.php')
-rw-r--r--engine/classes/ElggSession.php84
1 files changed, 70 insertions, 14 deletions
diff --git a/engine/classes/ElggSession.php b/engine/classes/ElggSession.php
index e34f7a961..1d59aaacc 100644
--- a/engine/classes/ElggSession.php
+++ b/engine/classes/ElggSession.php
@@ -4,34 +4,57 @@
* This class is intended to extend the $_SESSION magic variable by providing an API hook
* to plug in other values.
*
- * Primarily this is intended to provide a way of supplying "logged in user" details without touching the session
- * (which can cause problems when accessed server side).
+ * Primarily this is intended to provide a way of supplying "logged in user"
+ * details without touching the session (which can cause problems when
+ * accessed server side).
*
- * If a value is present in the session then that value is returned, otherwise a plugin hook 'session:get', '$var' is called,
- * where $var is the variable being requested.
+ * If a value is present in the session then that value is returned, otherwise
+ * a plugin hook 'session:get', '$var' is called, where $var is the variable
+ * being requested.
*
* Setting values will store variables in the session in the normal way.
*
* LIMITATIONS: You can not access multidimensional arrays
*
- * This is EXPERIMENTAL.
+ * @package Elgg.Core
+ * @subpackage Sessions
*/
class ElggSession implements ArrayAccess {
/** Local cache of trigger retrieved variables */
private static $__localcache;
+ /**
+ * Test if property is set either as an attribute or metadata.
+ *
+ * @param string $key The name of the attribute or metadata.
+ *
+ * @return bool
+ */
function __isset($key) {
return $this->offsetExists($key);
}
- /** Set a value, go straight to session. */
+ /**
+ * Set a value, go straight to session.
+ *
+ * @param string $key Name
+ * @param mixed $value Value
+ *
+ * @return void
+ */
function offsetSet($key, $value) {
$_SESSION[$key] = $value;
}
/**
- * Get a variable from either the session, or if its not in the session attempt to get it from
- * an api call.
+ * Get a variable from either the session, or if its not in the session
+ * attempt to get it from an api call.
+ *
+ * @see ArrayAccess::offsetGet()
+ *
+ * @param mixed $key Name
+ *
+ * @return void
*/
function offsetGet($key) {
if (!ElggSession::$__localcache) {
@@ -55,16 +78,28 @@ class ElggSession implements ArrayAccess {
}
/**
- * Unset a value from the cache and the session.
- */
+ * Unset a value from the cache and the session.
+ *
+ * @see ArrayAccess::offsetUnset()
+ *
+ * @param mixed $key Name
+ *
+ * @return void
+ */
function offsetUnset($key) {
unset(ElggSession::$__localcache[$key]);
unset($_SESSION[$key]);
}
/**
- * Return whether the value is set in either the session or the cache.
- */
+ * Return whether the value is set in either the session or the cache.
+ *
+ * @see ArrayAccess::offsetExists()
+ *
+ * @param int $offset Offset
+ *
+ * @return int
+ */
function offsetExists($offset) {
if (isset(ElggSession::$__localcache[$offset])) {
return true;
@@ -74,21 +109,42 @@ class ElggSession implements ArrayAccess {
return true;
}
- if ($this->offsetGet($offset)){
+ if ($this->offsetGet($offset)) {
return true;
}
}
- // Alias functions
+ /**
+ * Alias to ::offsetGet()
+ *
+ * @param string $key Name
+ *
+ * @return mixed
+ */
function get($key) {
return $this->offsetGet($key);
}
+ /**
+ * Alias to ::offsetSet()
+ *
+ * @param string $key Name
+ * @param mixed $value Value
+ *
+ * @return mixed
+ */
function set($key, $value) {
return $this->offsetSet($key, $value);
}
+ /**
+ * Alias to offsetUnset()
+ *
+ * @param string $key Name
+ *
+ * @return bool
+ */
function del($key) {
return $this->offsetUnset($key);
}