lithium\core\Libraries::_locateDeferred()
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|null
$defer
A boolean flag indicating which libraries to search, either the ones with the
'defer'
flag set, or the ones without. Providingnull
will cause the method to ignore the'defer'
flag set on any library and perform a complete lookup. -
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
stringReturns 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 = []) {
$libraries = static::$_configurations;
if (isset($options['library'])) {
$libraries = static::get((array) $options['library']);
}
foreach ($libraries as $library => $config) {
if ($config === null || $config['defer'] !== $defer && $defer !== null) {
continue;
}
foreach (static::_searchPaths($paths, $library) as $tpl) {
$params['library'] = rtrim($config['prefix'], '\\');
$class = str_replace('\\*', '', Text::insert($tpl, $params));
if (file_exists($file = Libraries::path($class, $options))) {
return ($options['type'] === 'file') ? $file : $class;
}
}
}
}