From 482fdb85a1fb81bfad2e20ec6bf24b5cc8354691 Mon Sep 17 00:00:00 2001 From: Marco Polichetti Date: Fri, 27 Jan 2017 00:15:03 +0100 Subject: [PATCH] Honor bundles configuration in controller injectors warmer --- HttpKernel/ControllerInjectorsWarmer.php | 17 +++++++++++++++-- Resources/config/services.xml | 2 ++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/HttpKernel/ControllerInjectorsWarmer.php b/HttpKernel/ControllerInjectorsWarmer.php index a5e987b..955cb13 100644 --- a/HttpKernel/ControllerInjectorsWarmer.php +++ b/HttpKernel/ControllerInjectorsWarmer.php @@ -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) @@ -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; } diff --git a/Resources/config/services.xml b/Resources/config/services.xml index 5259eee..d1f5ac5 100644 --- a/Resources/config/services.xml +++ b/Resources/config/services.xml @@ -65,6 +65,8 @@ %jms_di_extra.cache_warmer.controller_file_blacklist% + %jms_di_extra.all_bundles% + %jms_di_extra.bundles%