function ThemeHookCollectorPass::filterIterator
Same name and namespace in other branches
- main core/lib/Drupal/Core/Hook/ThemeHookCollectorPass.php \Drupal\Core\Hook\ThemeHookCollectorPass::filterIterator()
Filter iterator callback. Allows include files and .php files in src/Hook.
1 call to ThemeHookCollectorPass::filterIterator()
- ThemeHookCollectorPass::collectThemeHookImplementations in core/
lib/ Drupal/ Core/ Hook/ ThemeHookCollectorPass.php - Collects procedural and Attribute hook implementations.
File
-
core/
lib/ Drupal/ Core/ Hook/ ThemeHookCollectorPass.php, line 343
Class
- ThemeHookCollectorPass
- Collects and registers hook implementations.
Namespace
Drupal\Core\HookCode
protected static function filterIterator(\SplFileInfo $fileInfo, $key, \RecursiveDirectoryIterator $iterator) : bool {
$subPathName = $iterator->getSubPathname();
$extension = $fileInfo->getExtension();
if (str_starts_with($subPathName, 'src/Hook/')) {
return $iterator->isDir() || $extension === 'php';
}
if ($iterator->isDir()) {
if ($subPathName === 'src' || $subPathName === 'src/Hook') {
return TRUE;
}
// glob() doesn't support streams but scandir() does.
return !in_array($fileInfo->getFilename(), [
'tests',
'js',
'css',
'templates',
]) && !array_filter(scandir($key), static fn($filename) => str_ends_with($filename, '.info.yml'));
}
if ($fileInfo->getFilename() === 'theme-settings.php') {
return TRUE;
}
return in_array($extension, [
'inc',
'theme',
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.