public function LibrariesDirectoryFileFinder::find in Lightning Media 8.4
Finds files that are located in the supported 'libraries' directories.
It searches the following locations:
- A libraries directory in the current site directory, for example: sites/default/libraries.
- The root libraries directory.
- A libraries directory in the selected installation profile, for example: profiles/my_install_profile/libraries.
If the same library is present in multiple locations the first location found will be used. The locations are searched in the order listed.
Parameters
string $path: The path for the library file to find.
Return value
string|false The real path to the library file relative to the root directory. If the library cannot be found then FALSE.
File
- src/
LibrariesDirectoryFileFinder.php, line 84
Class
- LibrariesDirectoryFileFinder
- Looks for front-end JavaScript libraries in common directories.
Namespace
Drupal\lightning_mediaCode
public function find($path) {
// Search sites/<domain>/*.
$directories[] = "{$this->sitePath}/libraries/";
// Always search the root 'libraries' directory.
$directories[] = 'libraries/';
// Installation profiles can place libraries into a 'libraries' directory.
if ($this->installProfile) {
$profile_path = $this->profileExtensionList
->getPath($this->installProfile);
$directories[] = "{$profile_path}/libraries/";
}
foreach ($directories as $dir) {
if (file_exists($this->root . '/' . $dir . $path)) {
return $dir . $path;
}
}
// The library has not been found.
return FALSE;
}