lithium\storage\Session::read()
Reads a value from a persistent session store.
Parameters
-
string
$key
Key to be read.
-
array
$options
Optional parameters that this method accepts:
'name'
string: To force the read from a specific adapter, specify the name of the configuration (i.e.'default'
) here.'strategies'
boolean: Indicates whether or not a configuration's applied strategy classes should be enabled for this operation. Defaults totrue
.
Returns
mixedRead result on successful session read, null
otherwise.
Filter
This method can be filtered.
Source
public static function read($key = null, array $options = []) {
$defaults = ['name' => null, 'strategies' => true];
$options += $defaults;
$method = ($name = $options['name']) ? static::adapter($name)->read($key, $options) : null;
if (!$method) {
foreach (array_keys(static::$_configurations) as $name) {
if ($method = static::adapter($name)->read($key, $options)) {
break;
}
}
if (!$method || !$name) {
return null;
}
}
$params = compact('key', 'options');
$result = Filters::run(get_called_class(), __FUNCTION__, $params, $method);
if ($options['strategies']) {
return static::applyStrategies(__FUNCTION__, $name, $result, $options + [
'mode' => 'LIFO',
'key' => $key,
'class' => __CLASS__
]);
}
return $result;
}