diff --git a/README.md b/README.md index 6e07275..530cf88 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ On any action in a controller with the use statement, use these types of annotat /** * Route with parameter, name, constraint, and defaults - * @Route("/freedom/:param", name="easy-as-pie" constraints={"param":"[a-zA-Z]"}, defaults={"param":"index"}) + * @Route("/freedom/:param", name="easy-as-pie", constraints={"param":"[a-zA-Z]"}, defaults={"param":"index"}) */ public function anyOldNameAction(){ // ... diff --git a/bundle/Spec/CirclicalAutoWire/Annotations/OtherAnnotation.php b/bundle/Spec/CirclicalAutoWire/Annotations/OtherAnnotation.php new file mode 100644 index 0000000..8197bb3 --- /dev/null +++ b/bundle/Spec/CirclicalAutoWire/Annotations/OtherAnnotation.php @@ -0,0 +1,21 @@ + + * + * @Annotation + * @Target({"METHOD","CLASS"}) + */ +final class OtherAnnotation +{ + /** + * @var string + */ + public $value; + +} diff --git a/bundle/Spec/CirclicalAutoWire/Controller/OtherAnnotationsController.php b/bundle/Spec/CirclicalAutoWire/Controller/OtherAnnotationsController.php new file mode 100644 index 0000000..475a74d --- /dev/null +++ b/bundle/Spec/CirclicalAutoWire/Controller/OtherAnnotationsController.php @@ -0,0 +1,32 @@ +compile(); } + function it_skips_other_annotations() + { + include __DIR__ . '/../../CirclicalAutoWire/Controller/OtherAnnotationsController.php'; + AnnotationRegistry::registerAutoloadNamespace("Spec\\CirclicalAutoWire\\Annotations", realpath(__DIR__ . "/../../../")); + + $this->shouldNotThrow(\Error::class)->during('parseController', [OtherAnnotationsController::class]); + } + + function it_skips_other_annotations_type_error() + { + include __DIR__ . '/../../CirclicalAutoWire/Controller/OtherAnnotationsTypeErrorController.php'; + AnnotationRegistry::registerAutoloadNamespace("Spec\\CirclicalAutoWire\\Annotations", realpath(__DIR__ . "/../../../")); + + //this should be thrown, but I'm unable to force it... +// $this->shouldThrow(\TypeError::class)->during('parseController', [OtherAnnotationsTypeErrorController::class]); + $this->shouldNotThrow(\PhpSpec\Exception\Example\ErrorException::class)->during('parseController', [OtherAnnotationsTypeErrorController::class]); + } + function its_annotions_can_be_reset() { $this->parseController(SameNameAController::class); @@ -222,4 +243,4 @@ function its_annotions_can_be_reset() $this->getAnnotations()->shouldBeArray(); $this->getAnnotations()->shouldHaveCount(0); } -} \ No newline at end of file +} diff --git a/src/CirclicalAutoWire/Module.php b/src/CirclicalAutoWire/Module.php index 5a878fb..f66be6e 100644 --- a/src/CirclicalAutoWire/Module.php +++ b/src/CirclicalAutoWire/Module.php @@ -63,7 +63,7 @@ public function onBootstrap(MvcEvent $mvcEvent) $config = $serviceLocator->get('config'); $productionMode = Console::isConsole() || $config['circlical']['autowire']['production_mode']; - if (!$productionMode) { + if (!$productionMode || !file_exists($config['circlical']['autowire']['compile_to'])) { $routerService = $serviceLocator->get(RouterService::class); $directoryScanner = new DirectoryScanner(); @@ -87,6 +87,12 @@ public function onBootstrap(MvcEvent $mvcEvent) $writer = new PhpArray(); $writer->toFile($config['circlical']['autowire']['compile_to'], $routeConfig, true); $routerService->reset(); + + /** @var \Zend\ModuleManager\Listener\ConfigListener $cfg */ + $cfg = $serviceLocator->get(\Zend\ModuleManager\ModuleManager::class)->getEvent()->getConfigListener(); + if ($productionMode && $cfg->getOptions()->getConfigCacheEnabled() && file_exists($cfg->getOptions()->getConfigCacheFile())) { + @unlink($cfg->getOptions()->getConfigCacheFile()); + } } } -} \ No newline at end of file +}