Skip to content

Commit 029e3a3

Browse files
committed
Removing a user-contributed flag, which added logic that had it compile in production mode if the route file doesn't exist. This should solely be governed by the configuration (and environment).
1 parent 3687bc1 commit 029e3a3

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

bundle/Spec/CirclicalAutoWire/ModuleSpec.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function it_merges_with_existing_routes_in_production_mode_during_config_merge(M
8181
$this->configMerge($event);
8282
}
8383

84-
function it_scans_modules_during_bootstrap_in_dev_mode_only(MvcEvent $mvcEvent, Application $application, ContainerInterface $container)
84+
function it_scans_modules_during_bootstrap_in_dev_mode_only(MvcEvent $mvcEvent, Application $application, ContainerInterface $container, ModuleManager $moduleManager, ModuleEvent $event, ConfigListener $configListener)
8585
{
8686
$mvcEvent->getApplication()->willReturn($application);
8787
$application->getServiceManager()->willReturn($container);
@@ -92,12 +92,15 @@ function it_scans_modules_during_bootstrap_in_dev_mode_only(MvcEvent $mvcEvent,
9292
'circlical' => [
9393
'autowire' => [
9494
'production_mode' => false,
95-
'compile_to' => __DIR__ . '/compiled_routes.php',
95+
'compile_to' => __DIR__ . '/compiled_routes.php',
9696
],
9797
],
9898
]);
9999

100100
$container->get(RouterService::class)->willReturn(new RouterService(new TreeRouteStack(), false));
101+
$container->get(ModuleManager::class)->willReturn($moduleManager);
102+
$moduleManager->getEvent()->willReturn($event);
103+
$event->getConfigListener()->willReturn($configListener);
101104

102105
$this->onBootstrap($mvcEvent);
103106
}
@@ -113,7 +116,7 @@ function it_skips_compiling_in_prod_mode(MvcEvent $mvcEvent, Application $applic
113116
'circlical' => [
114117
'autowire' => [
115118
'production_mode' => true,
116-
'compile_to' => __DIR__ . '/compiled_routes.php',
119+
'compile_to' => __DIR__ . '/compiled_routes.php',
117120
],
118121
],
119122
]);

src/CirclicalAutoWire/Module.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ public function onBootstrap(MvcEvent $mvcEvent)
6363
$config = $serviceLocator->get('config');
6464
$productionMode = Console::isConsole() || $config['circlical']['autowire']['production_mode'];
6565

66-
if (!$productionMode || !file_exists($config['circlical']['autowire']['compile_to'])) {
66+
if (!$productionMode) {
67+
6768
$routerService = $serviceLocator->get(RouterService::class);
6869
$directoryScanner = new DirectoryScanner();
6970

@@ -83,15 +84,15 @@ public function onBootstrap(MvcEvent $mvcEvent)
8384
foreach ($controllerClasses as $controllerClass) {
8485
$routerService->parseController($controllerClass);
8586
}
87+
8688
$routeConfig = new Config($routerService->compile(), false);
8789
$writer = new PhpArray();
8890
$writer->toFile($config['circlical']['autowire']['compile_to'], $routeConfig, true);
8991
$routerService->reset();
9092

91-
/** @var \Zend\ModuleManager\Listener\ConfigListener $cfg */
92-
$cfg = $serviceLocator->get(\Zend\ModuleManager\ModuleManager::class)->getEvent()->getConfigListener();
93-
if ($productionMode && $cfg->getOptions()->getConfigCacheEnabled() && file_exists($cfg->getOptions()->getConfigCacheFile())) {
94-
@unlink($cfg->getOptions()->getConfigCacheFile());
93+
$configListener = $serviceLocator->get(ModuleManager::class)->getEvent()->getConfigListener();
94+
if ($productionMode && $configListener->getOptions()->getConfigCacheEnabled() && file_exists($configListener->getOptions()->getConfigCacheFile())) {
95+
@unlink($configListener->getOptions()->getConfigCacheFile());
9596
}
9697
}
9798
}

0 commit comments

Comments
 (0)