lithium\core\Libraries::_transformPath()
Handles the conversion of a class name to a file name using a custom transformation typically
defined in the 'transform'
key of a configuration defined through Libraries::add()
.
The transformation can either be a closure which receives two parameters (the class name as a string, and the library configuration as an array), or an array with two values (one being the pattern to match, the other being the replacement).
Parameters
-
mixed
$transform
Either a closure or an array containing a regular expression match and replacement. If the closure returns an empty value, or the regular expression fails to match, will return
null
. -
string
$class
The class name which is attempting to be mapped to a file.
-
array
$options
The configuration of the library as passed to
Libraries::add()
, along with any options specified in the call toLibraries::path()
.
Returns
stringReturns transformed path of a class to a file, or null
if the transformation
did not match.
Source
protected static function _transformPath($transform, $class, array $options = array()) {
if ((is_callable($transform)) && $file = $transform($class, $options)) {
return $file;
}
if (is_array($transform)) {
list($match, $replace) = $transform;
return preg_replace($match, $replace, $class) ?: null;
}
}