lithium\core\Adaptable::strategies()
Obtain an SplDoublyLinkedList
of the strategies for the given $name
configuration, using
the $_strategies
path defined in Adaptable
subclasses.
Parameters
-
string
$name
Class name of adapter to load.
Returns
objectSplDoublyLinkedList
of strategies, or null
if none are defined.
Source
public static function strategies($name) {
$config = static::_config($name);
if ($config === null) {
throw new ConfigException("Configuration `{$name}` has not been defined.");
}
if (!isset($config['strategies'])) {
return null;
}
$stack = new SplDoublyLinkedList();
foreach ($config['strategies'] as $key => $strategy) {
if (!is_array($strategy)) {
$name = $strategy;
$class = static::_strategy($name, static::$_strategies);
$stack->push(new $class());
continue;
}
$class = static::_strategy($key, static::$_strategies);
$index = (isset($config['strategies'][$key])) ? $key : $class;
$stack->push(new $class($config['strategies'][$index]));
}
return $stack;
}