You are here

function Psr4FinderPlugin::findFile in X Autoload 7.5

Same name and namespace in other branches
  1. 7.4 lib/ClassFinder/Plugin/Psr4FinderPlugin.php \Drupal\xautoload\ClassFinder\Plugin\Psr4FinderPlugin::findFile()

Parameters

FindFileInjectedApi $api: An object with a suggestFile() method. We are supposed to suggest files until suggestFile() returns TRUE, or we have no more suggestions.

string $logical_base_path: The key that this plugin was registered with. With trailing '/'.

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

int|string $base_dir: Id under which the plugin was registered. This should be the PSR-4 base directory.

Return value

bool|null TRUE, if the file was found. FALSE, otherwise.

Overrides xautoload_FinderPlugin_Interface::findFile

File

src/ClassFinder/Plugin/Psr4FinderPlugin.php, line 27

Class

Psr4FinderPlugin

Namespace

Drupal\xautoload\ClassFinder\Plugin

Code

function findFile($api, $logical_base_path, $relative_path, $base_dir = NULL) {

  // The $relative_path has the replacements from PSR-0, which we don't want.
  // So we need to re-calculate it.
  $relative_classname = substr($api
    ->getClass(), strlen($logical_base_path));
  $relative_path = str_replace('\\', '/', $relative_classname) . '.php';
  return $api
    ->suggestFile($base_dir . '/' . $relative_path);
}