You are here

static function Util::findFileInIncludePath in X Autoload 7.4

Same name and namespace in other branches
  1. 7.5 src/Util.php \Drupal\xautoload\Util::findFileInIncludePath()

Check if a file exists, considering the full include path. Return the resolved path to that file.

Parameters

string $file: The filepath

Return value

boolean|string The resolved file path, if the file exists in the include path. FALSE, otherwise.

3 calls to Util::findFileInIncludePath()
FindFileInjectedApi::suggestFile_checkIncludePath in lib/ClassFinder/InjectedApi/FindFileInjectedApi.php
Same as suggestFile(), but check the full PHP include path.
LoadClassGetFileInjectedApi::suggestFile_checkIncludePath in lib/ClassFinder/InjectedApi/LoadClassGetFileInjectedApi.php
Same as suggestFile(), but check the full PHP include path.
LoadClassInjectedAPI::suggestFile_checkIncludePath in lib/ClassFinder/InjectedApi/LoadClassInjectedAPI.php
Same as suggestFile(), but check the full PHP include path.

File

lib/Util.php, line 167

Class

Util
A number of static methods that don't interact with any global state.

Namespace

Drupal\xautoload

Code

static function findFileInIncludePath($file) {
  if (function_exists('stream_resolve_include_path')) {

    // Use the PHP 5.3.1+ way of doing this.
    return stream_resolve_include_path($file);
  }
  elseif ($file[0] === '/') {

    // That's an absolute path already.
    return file_exists($file) ? $file : FALSE;
  }
  else {

    // Manually loop all candidate paths.
    foreach (explode(PATH_SEPARATOR, get_include_path()) as $base_dir) {
      if (file_exists($base_dir . '/' . $file)) {
        return $base_dir . '/' . $file;
      }
    }
    return FALSE;
  }
}