You are here

function xautoload_ClassFinder_Helper_Map::findFile_nested in X Autoload 7.2

Find the file for a class that in PSR-0 or PEAR would be in $psr_0_root . '/' . $first_part . $second_part

Parameters

string $first_part: First part of the canonical path, with trailing DIRECTORY_SEPARATOR.

string $second_part: Second part of the canonical path, ending with '.php'.

File

lib/ClassFinder/Helper/Map.php, line 122

Class

xautoload_ClassFinder_Helper_Map
Helper class for the class finder. This is not part of ClassFinder, because we want to use the same logic for namespaces (PSR-0) and prefixes (PEAR).

Code

function findFile_nested($api, $first_part, $second_part) {

  // Check any paths registered for this namespace.
  if (isset($this->nsPaths[$first_part])) {
    $lazy_remove = FALSE;
    foreach ($this->nsPaths[$first_part] as $dir => $lazy_check) {
      $file = $dir . $second_part;
      if ($api
        ->suggestFile($file)) {
        return TRUE;
      }
      if ($lazy_check && !$api
        ->is_dir($dir)) {

        // This is the best place to lazy-check whether a directory exists.
        unset($this->nsPaths[$first_part][$dir]);
        $lazy_remove = TRUE;
      }
    }
    if ($lazy_remove && empty($this->nsPaths[$first_part])) {
      unset($this->nsPaths[$first_part]);
    }
  }

  // Check any plugin registered for this namespace.
  if (isset($this->nsPlugins[$first_part])) {
    foreach ($this->nsPlugins[$first_part] as $plugin) {
      if ($plugin
        ->findFile($api, $first_part, $second_part)) {
        return TRUE;
      }
    }
  }
}