protected function WildcardFileFinder::scanDirectory in X Autoload 7.4
Same name and namespace in other branches
- 7.5 src/Discovery/WildcardFileFinder.php \Drupal\xautoload\Discovery\WildcardFileFinder::scanDirectory()
Parameters
string $dir: Base folder, e.g. "sites/all/modules/foo/includes", which does NOT contain any asterisk ("*").
string $wildcard: Suffix which may contain asterisks.
3 calls to WildcardFileFinder::scanDirectory()
- WildcardFileFinder::addDrupalPaths in lib/
Discovery/ WildcardFileFinder.php - WildcardFileFinder::addPaths in lib/
Discovery/ WildcardFileFinder.php - WildcardFileFinder::scanDirectoryLevel in lib/
Discovery/ WildcardFileFinder.php
File
- lib/
Discovery/ WildcardFileFinder.php, line 99
Class
- WildcardFileFinder
- Scan directories for wildcard files[] instructions in a module's info file.
Namespace
Drupal\xautoload\DiscoveryCode
protected function scanDirectory($dir, $wildcard) {
if (!is_dir($dir)) {
return;
}
if (FALSE === strpos($wildcard, '*')) {
// $wildcard is a fixed string, not a wildcard.
$this
->suggestFile($dir . '/' . $wildcard);
}
elseif ('**' === $wildcard) {
// Trick: "$a/**" == union of "$a/*" and "$a/*/**"
$this
->scanDirectoryLevel($dir, '*');
$this
->scanDirectoryLevel($dir, '*', '**');
}
elseif ('**/' === substr($wildcard, 0, 3)) {
// Trick: "$a/**/$b" == union of "$a/$b" and "$a/*/**/$b"
$remaining = substr($wildcard, 3);
$this
->scanDirectory($dir, $remaining);
$this
->scanDirectoryLevel($dir, '*', $wildcard);
}
elseif (FALSE !== ($slashpos = strpos($wildcard, '/'))) {
// $wildcard consists of more than one fragment.
$fragment = substr($wildcard, 0, $slashpos);
$remaining = substr($wildcard, $slashpos + 1);
if (FALSE === strpos($fragment, '*')) {
$this
->scanDirectory($dir . '/' . $fragment, $remaining);
}
else {
$this
->scanDirectoryLevel($dir, $fragment, $remaining);
}
}
else {
// $wildcard represents a file name.
$this
->scanDirectoryLevel($dir, $wildcard);
}
}