Skip to content

Commit

Permalink
Merge pull request #288 from gremo/fix-controller-injections
Browse files Browse the repository at this point in the history
Fix controller injections when there are no dirs to scan
  • Loading branch information
GuilhemN authored Sep 30, 2017
2 parents 55c3f87 + f1040b3 commit 2116253
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions HttpKernel/ControllerInjectorsWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,15 @@ private function findControllerClasses()
$dirs[] = $controllerDir;
}

foreach (Finder::create()->name('*Controller.php')->in($dirs)->files() as $file) {
$filename = $file->getRealPath();
if (!in_array($filename, $this->blackListedControllerFiles)) {
require_once $filename;
// Combination of scanAllBundles/scanBundles can lead to empty dirs.
// Only search for controllers if we have at least one directory,
// otherwise the finder will throw an exception.
if (!empty($dirs)) {
foreach (Finder::create()->name('*Controller.php')->in($dirs)->files() as $file) {
$filename = $file->getRealPath();
if (!in_array($filename, $this->blackListedControllerFiles)) {
require_once $filename;
}
}
}

Expand Down

0 comments on commit 2116253

Please sign in to comment.