@@ -37,8 +37,8 @@ final class ApplicationExtension extends Nette\DI\CompilerExtension
3737 /** @var int */
3838 private $ invalidLinkMode ;
3939
40- /** @var string */
41- private $ tempFile ;
40+ /** @var string|null */
41+ private $ tempDir ;
4242
4343
4444 public function __construct (bool $ debugMode = false , array $ scanDirs = null , string $ tempDir = null )
@@ -48,7 +48,7 @@ public function __construct(bool $debugMode = false, array $scanDirs = null, str
4848 $ this ->defaults ['scanComposer ' ] = class_exists (ClassLoader::class);
4949 $ this ->defaults ['catchExceptions ' ] = !$ debugMode ;
5050 $ this ->debugMode = $ debugMode ;
51- $ this ->tempFile = $ tempDir ? $ tempDir . ' / ' . urlencode ( __CLASS__ ) : null ;
51+ $ this ->tempDir = $ tempDir ;
5252 }
5353
5454
@@ -71,7 +71,7 @@ public function loadConfiguration()
7171 $ application ->addSetup ([Nette \Bridges \ApplicationTracy \RoutingPanel::class, 'initializePanel ' ]);
7272 }
7373
74- $ touch = $ this ->debugMode && $ config ['scanDirs ' ] ? $ this ->tempFile : null ;
74+ $ touch = $ this ->debugMode && $ config ['scanDirs ' ] && $ this -> tempDir ? $ this ->tempDir . ' /touch ' : null ;
7575 $ presenterFactory = $ builder ->addDefinition ($ this ->prefix ('presenterFactory ' ))
7676 ->setType (Nette \Application \IPresenterFactory::class)
7777 ->setFactory (Nette \Application \PresenterFactory::class, [new Nette \DI \Definitions \Statement (
@@ -132,11 +132,16 @@ private function findPresenters(): array
132132 throw new Nette \NotSupportedException ("RobotLoader is required to find presenters, install package `nette/robot-loader` or disable option {$ this ->prefix ('scanDirs ' )}: false " );
133133 }
134134 $ robot = new Nette \Loaders \RobotLoader ;
135- $ robot ->addDirectory ($ config ['scanDirs ' ]);
135+ $ robot ->addDirectory (... $ config ['scanDirs ' ]);
136136 $ robot ->acceptFiles = ['* ' . $ config ['scanFilter ' ] . '*.php ' ];
137- $ robot ->rebuild ();
137+ if ($ this ->tempDir ) {
138+ $ robot ->setTempDirectory ($ this ->tempDir );
139+ $ robot ->refresh ();
140+ } else {
141+ $ robot ->rebuild ();
142+ }
138143 $ classes = array_keys ($ robot ->getIndexedClasses ());
139- $ this ->getContainerBuilder ()->addDependency ($ this ->tempFile );
144+ $ this ->getContainerBuilder ()->addDependency ($ this ->tempDir . ' /touch ' );
140145 }
141146
142147 if ($ config ['scanComposer ' ]) {
0 commit comments