function xautoload_ClassFinder_Prefix::registerPrefixRoot in X Autoload 7.3
Same name and namespace in other branches
- 7.2 lib/ClassFinder/Prefix.php \xautoload_ClassFinder_Prefix::registerPrefixRoot()
Register a PEAR-style root path for a given class prefix.
Parameters
string $prefix: Prefix, e.g. "My_Prefix", for classes like "My_Prefix_SomeClass". This does ALSO cover the class named "My_Prefix" itself.
string $root_path: Root path, e.g. "../lib" or "../src", so that classes can be placed e.g. My_Prefix_SomeClass -> ../lib/My/Prefix/SomeClass.php My_Prefix -> ../lib/My/Prefix.php
bool|xautoload_MissingDirPlugin_Interface $lazy_check: If TRUE, then we are not sure if the directory at $path actually exists. If during the process we find the directory to be nonexistent, we unregister the path.
File
- lib/
ClassFinder/ Prefix.php, line 35
Class
Code
function registerPrefixRoot($prefix, $root_path, $lazy_check = TRUE) {
$prefix_path_fragment = $this
->prefixPathFragment($prefix);
$deep_path = strlen($root_path) ? $root_path . DIRECTORY_SEPARATOR : $root_path;
$deep_path .= $prefix_path_fragment;
$this->prefixMap
->registerDeepPath($prefix_path_fragment, $deep_path, $lazy_check);
if (strlen($prefix)) {
// We assume that the class named $prefix is also found at this path.
$filepath = substr($deep_path, 0, -1) . '.php';
$this
->registerClass($prefix, $filepath);
}
}