Performs service location lookups by library, based on the library's `'defer'` flag.
Libraries with `'defer'` set to `true` will be searched last when looking up services.
Parameters
- boolean $defer A boolean flag indicating which libraries to search, either the ones with the `'defer'` flag set, or the ones without.
- array $paths List of paths to be searched for the given service (class). These are defined in `lithium\core\Libraries::$_paths`, and are organized by class type.
- array $params The list of insert parameters to be injected into each path format string when searching for classes.
- array $options
Returns
string Returns a class path as a string if a given class is found, or null if no class in any path matching any of the parameters is located.Source
protected static function _locateDeferred($defer, $paths, $params, array $options = array()) {
$libraries = static::$_configurations;
if (isset($options['library'])) {
$libraries = static::get((array) $options['library']);
}
foreach ($libraries as $library => $config) {
if ($config['defer'] !== $defer && $defer !== null) {
continue;
}
foreach (static::_searchPaths($paths, $library, $params) as $tpl) {
$params['library'] = rtrim($config['prefix'], '\\');
$class = str_replace('\\*', '', String::insert($tpl, $params));
if (file_exists($file = Libraries::path($class, $options))) {
return ($options['type'] === 'file') ? $file : $class;
}
}
}
}