function RetrieveRoutingFilesTrait::routingFilesCallback
Callback to filter Drupal routing files.
Parameters
mixed $current: The element being filtered.
string $key: The element key.
mixed $iterator: The iterator.
Return value
bool Whether the current file is a Drupal config file.
2 calls to RetrieveRoutingFilesTrait::routingFilesCallback()
- RoutePathTest::providerRoutingFiles in tests/
src/ Unit/ RoutePathTest.php - Provides test data for testPathStartsWithSlash().
- TraitsTest::providerRoutingFiles in tests/
src/ Unit/ TraitsTest.php - Provides test data for testRoutingFilesCallback().
File
-
tests/
src/ Unit/ RetrieveRoutingFilesTrait.php, line 23
Class
- RetrieveRoutingFilesTrait
- Trait for test that needs to retrieve routing files.
Namespace
Drupal\Tests\examples\UnitCode
protected static function routingFilesCallback(mixed $current, string $key, mixed $iterator) : bool {
// A Drupal routing file has a filename that ends with .routing.yml, and it
// is contained in a directory containing a .info.yml file with the same
// name.
// For example, node.routing.yml is a routing file if in the same directory
// there is also a node.info.yml file.
/** @var \SplFileInfo $current */
/** @var \RecursiveDirectoryIterator $iterator */
if (str_ends_with($current->getFileName(), '.routing.yml')) {
return file_exists(substr($current->getPathName(), 0, -12) . '.info.yml');
}
return FALSE;
}