From 6cb8afc72db6c6a1c1ca41614d82bef0a364619a Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Fri, 16 May 2008 06:55:57 +0000 Subject: [PATCH] Session: Add getDataOfType function, which retrieves all data of the given type from the data store. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@578 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/Session.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php index 003c3db73..232713439 100644 --- a/lib/SimpleSAML/Session.php +++ b/lib/SimpleSAML/Session.php @@ -637,6 +637,38 @@ class SimpleSAML_Session { } + /** + * This function retrieves all data of the specified type from the data store. + * + * The data will be returned as an associative array with the id of the data as the key, and the data + * as the value of each key. The value will be stored as a copy of the original data. setData must be + * used to update the data. + * + * An empty array will be returned if no data of the given type is found. + * + * @param $type The type of the data. + * @return An associative array with all data of the given type. + */ + public function getDataOfType($type) { + assert('is_string($type)'); + + if(!is_array($this->dataStore)) { + return array(); + } + + if(!array_key_exists($type, $this->dataStore)) { + return array(); + } + + $ret = array(); + foreach($this->dataStore[$type] as $id => $info) { + $ret[$id] = $info['data']; + } + + return $ret; + } + + /** * Load a session from the session handler. * -- GitLab