You are here

function xautoload_ClassFinder_Prefix::registerPrefixesRoot in X Autoload 7.3

Register an array of PEAR-style deep paths for given class prefixes.

Note: This actually goes beyond PEAR style, because it also allows "shallow" PEAR-like structures like my_library_Some_Class -> (library dir)/src/Some/Class.php instead of my_library_Some_Class -> (library dir)/src/my/library/Some/Class.php via $finder->registerPrefixDeep('my_library', "$library_dir/src");

Parameters

array $map: Associative array, the keys are the prefixes, the values are the directories. This does NOT cover the class named $prefix itself.

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 69

Class

xautoload_ClassFinder_Prefix

Code

function registerPrefixesRoot($map, $lazy_check = TRUE) {
  $deep_map = array();
  foreach ($map as $prefix => $path) {
    $prefix_path_fragment = $this
      ->prefixPathFragment($prefix);
    $deep_path = strlen($path) ? $path . DIRECTORY_SEPARATOR : '';
    $deep_path .= $prefix_path_fragment;
    $deep_map[$prefix_path_fragment][$deep_path] = $lazy_check;

    // Register the class with name $prefix.
    if (strlen($prefix)) {
      $filepath = substr($deep_path, 0, -1) . '.php';
      $this->classes[$prefix][$filepath] = TRUE;
    }
  }
  $this->prefixMap
    ->registerDeepPaths($deep_map);
}