diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-05-28 16:52:40 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-05-28 16:52:40 +0200 |
commit | 57f712f8a9e638157f1f7ce8158791834a365ee5 (patch) | |
tree | cb3eed810e42c6d82487ec25ef414fef7c60df05 /lib/session | |
parent | cc0cf931365d0c515038015bc7792f8500fafcc3 (diff) | |
download | nextcloud-server-57f712f8a9e638157f1f7ce8158791834a365ee5.tar.gz nextcloud-server-57f712f8a9e638157f1f7ce8158791834a365ee5.zip |
implement ArrayInterface with Session
Diffstat (limited to 'lib/session')
-rw-r--r-- | lib/session/memory.php | 2 | ||||
-rw-r--r-- | lib/session/session.php | 45 |
2 files changed, 39 insertions, 8 deletions
diff --git a/lib/session/memory.php b/lib/session/memory.php index 4202ddfd2fc..c148ff4b9b9 100644 --- a/lib/session/memory.php +++ b/lib/session/memory.php @@ -15,7 +15,7 @@ namespace OC\Session; * * @package OC\Session */ -class Memory implements Session { +class Memory extends Session { protected $data; public function __construct($name) { diff --git a/lib/session/session.php b/lib/session/session.php index 3dce3b7f5b3..55515f57a87 100644 --- a/lib/session/session.php +++ b/lib/session/session.php @@ -8,41 +8,72 @@ namespace OC\Session; -interface Session { +abstract class Session implements \ArrayAccess { /** * $name serves as a namespace for the session keys * * @param string $name */ - public function __construct($name); + abstract public function __construct($name); /** * @param string $key * @param mixed $value */ - public function set($key, $value); + abstract public function set($key, $value); /** * @param string $key * @return mixed should return null if $key does not exist */ - public function get($key); + abstract public function get($key); /** * @param string $key * @return bool */ - public function exists($key); + abstract public function exists($key); /** * should not throw any errors if $key does not exist * * @param string $key */ - public function remove($key); + abstract public function remove($key); /** * removes all entries within the cache namespace */ - public function clear(); + abstract public function clear(); + + /** + * @param mixed $offset + * @return bool + */ + public function offsetExists($offset) { + return $this->exists($offset); + } + + /** + * @param mixed $offset + * @return mixed + */ + public function offsetGet($offset) { + return $this->get($offset); + } + + /** + * @param mixed $offset + * @param mixed $value + */ + public function offsetSet($offset, $value) { + $this->set($offset, $value); + } + + /** + * @param mixed $offset + */ + public function offsetUnset($offset) { + $this->remove($offset); + } } |