Skip to content

Commit

Permalink
ApplicationExtension: option 'scanFilter' changed to pattern, default…
Browse files Browse the repository at this point in the history
… is '*Presenter'
  • Loading branch information
dg committed Dec 31, 2020
1 parent 0e7442d commit 00dc017
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Bridges/ApplicationDI/ApplicationExtension.php
Expand Up @@ -63,7 +63,7 @@ public function getConfigSchema(): Nette\Schema\Schema
false
)->default($this->scanDirs),
'scanComposer' => Expect::bool(class_exists(ClassLoader::class)),
'scanFilter' => Expect::string('Presenter'),
'scanFilter' => Expect::string('*Presenter'),
'silentLinks' => Expect::bool(),
]);
}
Expand Down Expand Up @@ -159,7 +159,7 @@ private function findPresenters(): array
}
$robot = new Nette\Loaders\RobotLoader;
$robot->addDirectory(...$config->scanDirs);
$robot->acceptFiles = ['*' . $config->scanFilter . '*.php'];
$robot->acceptFiles = [$config->scanFilter . '.php'];
if ($this->tempDir) {
$robot->setTempDirectory($this->tempDir);
$robot->refresh();
Expand Down Expand Up @@ -191,7 +191,7 @@ private function findPresenters(): array
$presenters = [];
foreach (array_unique($classes) as $class) {
if (
strpos($class, $config->scanFilter) !== false
fnmatch($config->scanFilter, $class)
&& class_exists($class)
&& ($rc = new \ReflectionClass($class))
&& $rc->implementsInterface(Nette\Application\IPresenter::class)
Expand Down
4 changes: 4 additions & 0 deletions tests/Bridges.DI/ApplicationExtension.scan.phpt
Expand Up @@ -40,6 +40,7 @@ test('', function () {
$code = $compiler->addConfig([
'application' => [
'scanDirs' => [__DIR__ . '/files'],
'scanFilter' => '*Presenter*',
],
])->setClassName('Container2')->compile();
eval($code);
Expand All @@ -61,6 +62,9 @@ test('', function () {
$builder->addDefinition('myHttpResponse')->setFactory(Nette\Http\Response::class);
$loader = new DI\Config\Loader;
$config = $loader->load(Tester\FileMock::create('
application:
scanFilter: *Presenter*
services:
-
factory: Presenter1
Expand Down

0 comments on commit 00dc017

Please sign in to comment.