[Server] Allow overriding the default file name pattern for Discovery (#292)
* Add optional namePatterns capability to discovery so that the default scan for `*.php` files can be overridden. * add default to namePatterns docs * add an error check if we manage to pass in an empty list of patterns * add unit tests (and a static entry to classmap for composer.json so it autoloads from a non .php file for the test) * run php-cs-fixer * change how default namePatterns are set and make sure all the annotations are correct * Fix bad whitespace Co-authored-by: Christopher Hertel <mail@christopher-hertel.de> * switch to a const default instead of nullable with a check in the function to convert null to a default * make sure we handle empty arrays * formatting fixes * Apply suggestion from @chr-hertel Co-authored-by: Christopher Hertel <mail@christopher-hertel.de> * Add changelog entry --------- Co-authored-by: Christopher Hertel <mail@christopher-hertel.de>
This commit is contained in:
parent
fb2c8c2ee4
commit
86bd845924
1 changed files with 109 additions and 37 deletions
|
|
@ -24,18 +24,20 @@ final class DiscoveryLoader implements LoaderInterface
|
|||
/**
|
||||
* @param string[] $scanDirs
|
||||
* @param array|string[] $excludeDirs
|
||||
* @param string[] $namePatterns
|
||||
*/
|
||||
public function __construct(
|
||||
private string $basePath,
|
||||
private array $scanDirs,
|
||||
private array $excludeDirs,
|
||||
private DiscovererInterface $discoverer,
|
||||
private array $namePatterns = DiscovererInterface::DEFAULT_NAME_PATERNS,
|
||||
) {
|
||||
}
|
||||
|
||||
public function load(RegistryInterface $registry): void
|
||||
{
|
||||
$discoveryState = $this->discoverer->discover($this->basePath, $this->scanDirs, $this->excludeDirs);
|
||||
$discoveryState = $this->discoverer->discover($this->basePath, $this->scanDirs, $this->excludeDirs, $this->namePatterns);
|
||||
|
||||
$registry->setDiscoveryState($discoveryState);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue