diff --git a/composer.json b/composer.json index ffc7709..bf678c4 100644 --- a/composer.json +++ b/composer.json @@ -47,6 +47,9 @@ "extra": { "branch-alias": { "dev-master": "1.0-dev" + }, + "zf": { + "config-provider": "TwbBundle\\ConfigProvider" } } } diff --git a/src/TwbBundle/ConfigProvider.php b/src/TwbBundle/ConfigProvider.php new file mode 100644 index 0000000..e122da2 --- /dev/null +++ b/src/TwbBundle/ConfigProvider.php @@ -0,0 +1,78 @@ +moduleConfig = require self::MODULE_CONFIG_PATH; + + return [ + 'twbbundle' => $this->getTwbBundleOptions(), + 'dependencies' => $this->getDependencies(), + 'view_helpers' => $this->getViewHelpers() + ]; + } + + /** + * Returns twb bundle options + * + * @return array + */ + protected function getTwbBundleOptions() + { + return array_key_exists('twbbundle', $this->moduleConfig) ? $this->moduleConfig['twbbundle'] : []; + } + + /** + * Returns dependencies (former server_manager) + * + * @return array + */ + protected function getDependencies() + { + return array_key_exists('service_manager', $this->moduleConfig) ? $this->moduleConfig['service_manager'] : []; + } + + /** + * Returns view helpers + * + * @return array + */ + protected function getViewHelpers() + { + return array_key_exists('view_helpers', $this->moduleConfig) ? $this->moduleConfig['view_helpers'] : []; + } +} diff --git a/tests/TwbBundleTest/ConfigProviderTest.php b/tests/TwbBundleTest/ConfigProviderTest.php new file mode 100644 index 0000000..fa27231 --- /dev/null +++ b/tests/TwbBundleTest/ConfigProviderTest.php @@ -0,0 +1,43 @@ +configProvider = new ConfigProvider(); + } + + /** + * Tests valid return values + */ + public function testInvokeReturnValues() + { + $config = $this->configProvider->__invoke(); + + $this->assertArrayHasKey('twbbundle', $config); + $this->assertArrayHasKey('dependencies', $config); + $this->assertArrayHasKey('view_helpers', $config); + + $this->assertNotEmpty($config['twbbundle']); + $this->assertNotEmpty($config['dependencies']); + $this->assertNotEmpty($config['view_helpers']); + } +}