Skip to content

Commit

Permalink
Merge pull request #270 from gremo/fix-controllers-warmer
Browse files Browse the repository at this point in the history
Honor bundles configuration in controller injectors warmer
  • Loading branch information
GuilhemN authored Sep 27, 2017
2 parents 4adca6b + 482fdb8 commit 55c3f87
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 15 additions & 2 deletions HttpKernel/ControllerInjectorsWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,21 @@ class ControllerInjectorsWarmer implements CacheWarmerInterface
private $kernel;
private $controllerResolver;
private $blackListedControllerFiles;
private $scanAllBundles;
private $scanBundles;

public function __construct(KernelInterface $kernel, ControllerResolver $resolver, array $blackListedControllerFiles)
{
public function __construct(
KernelInterface $kernel,
ControllerResolver $resolver,
array $blackListedControllerFiles,
$scanAllBundles = true,
array $scanBundles = array()
) {
$this->kernel = $kernel;
$this->controllerResolver = $resolver;
$this->blackListedControllerFiles = $blackListedControllerFiles;
$this->scanAllBundles = $scanAllBundles;
$this->scanBundles = $scanBundles;
}

public function warmUp($cacheDir)
Expand Down Expand Up @@ -63,6 +72,10 @@ private function findControllerClasses()
{
$dirs = array();
foreach ($this->kernel->getBundles() as $bundle) {
if (!$this->scanAllBundles && !in_array($bundle->getName(), $this->scanBundles, true)) {
continue;
}

if (!is_dir($controllerDir = $bundle->getPath().'/Controller')) {
continue;
}
Expand Down
2 changes: 2 additions & 0 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
<argument type="service" id="kernel" />
<argument type="service" id="jms_di_extra.controller_resolver" />
<argument>%jms_di_extra.cache_warmer.controller_file_blacklist%</argument>
<argument>%jms_di_extra.all_bundles%</argument>
<argument>%jms_di_extra.bundles%</argument>
</service>
</services>
</container>

0 comments on commit 55c3f87

Please sign in to comment.