public static function locate($type, $name = null, array $options = array())
{
if (is_object($name) || strpos($name, '\\') !== false) {
return $name;
}
$ident = $name ? $type . '.' . $name : $type . '.*';
$ident .= $options ? '.' . md5(serialize($options)) : null;
if (isset(static::$_cachedPaths[$ident])) {
return static::$_cachedPaths[$ident];
}
$params = static::_params($type, $name);
$defaults = array('type' => 'class', 'library' => $params['library'] !== '*' ? $params['library'] : null);
$options += $defaults;
unset($params['library']);
$paths = static::paths($params['type']);
if (!isset($paths)) {
return null;
}
if ($params['name'] === '*') {
$result = static::_locateAll($params, $options);
return static::$_cachedPaths[$ident] = $result;
}
if ($options['library']) {
$result = static::_locateDeferred(null, $paths, $params, $options);
return static::$_cachedPaths[$ident] = $result;
}
foreach (array(false, true) as $defer) {
if ($result = static::_locateDeferred($defer, $paths, $params, $options)) {
return static::$_cachedPaths[$ident] = $result;
}
}
}