diff --git a/composer.json b/composer.json index 39da7e5..e2717c7 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,8 @@ ], "extra": { "laminas": { - "module": "LmcCors" + "module": "LmcCors", + "config-provider": "LmcCors\\ConfigProvider" } }, "require": { diff --git a/src/ConfigProvider.php b/src/ConfigProvider.php new file mode 100644 index 0000000..f731f00 --- /dev/null +++ b/src/ConfigProvider.php @@ -0,0 +1,31 @@ + $this->getDependencyConfig(), + 'lmc_cors' => $this->getModuleConfig(), + ]; + } + + public function getDependencyConfig(): array + { + return [ + 'factories' => [ + Mvc\CorsRequestListener::class => Factory\CorsRequestListenerFactory::class, + Options\CorsOptions::class => Factory\CorsOptionsFactory::class, + Service\CorsService::class => Factory\CorsServiceFactory::class, + ], + ]; + } + + public function getModuleConfig(): array + { + return [ + ]; + } +} diff --git a/src/Module.php b/src/Module.php index 5399e38..48394b7 100644 --- a/src/Module.php +++ b/src/Module.php @@ -49,8 +49,13 @@ public function onBootstrap(EventInterface $e): void /** * {@inheritDoc} */ - public function getConfig() + public function getConfig(): array { - return include __DIR__ . '/../config/module.config.php'; + $configProvider = new ConfigProvider(); + + return [ + 'service_manager' => $configProvider->getDependencyConfig(), + 'lmc_cors' => $configProvider->getModuleConfig(), + ]; } } diff --git a/tests/ConfigProviderTest.php b/tests/ConfigProviderTest.php new file mode 100644 index 0000000..538e41f --- /dev/null +++ b/tests/ConfigProviderTest.php @@ -0,0 +1,18 @@ +assertArrayHasKey('dependencies', $config); + $this->assertArrayHasKey('lmc_cors', $config); + $this->assertArrayHasKey('factories', $config['dependencies']); + } +}