diff --git a/CHANGELOG.md b/CHANGELOG.md index 78a3e46..a57ff8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file, in reverse ### Added -- Nothing. +- [#3](https://github.com/zendframework/zend-config-aggregator-modulemanager/pull/3) adds support for `ViewHelperProviderInterface` ### Changed diff --git a/composer.lock b/composer.lock index 572d40d..7383d0f 100644 --- a/composer.lock +++ b/composer.lock @@ -1,7 +1,7 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], "content-hash": "d243c3d9b8ce6b814aaffa8d5ebd07c7", @@ -1159,6 +1159,7 @@ "mock", "xunit" ], + "abandoned": true, "time": "2018-02-15T05:27:38+00:00" }, { @@ -1726,16 +1727,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "2.9.1", + "version": "2.9.2", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "dcbed1074f8244661eecddfc2a675430d8d33f62" + "reference": "2acf168de78487db620ab4bc524135a13cfe6745" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dcbed1074f8244661eecddfc2a675430d8d33f62", - "reference": "dcbed1074f8244661eecddfc2a675430d8d33f62", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/2acf168de78487db620ab4bc524135a13cfe6745", + "reference": "2acf168de78487db620ab4bc524135a13cfe6745", "shasum": "" }, "require": { @@ -1800,7 +1801,7 @@ "phpcs", "standards" ], - "time": "2017-05-22T02:43:20+00:00" + "time": "2018-11-07T22:31:41+00:00" }, { "name": "theseer/tokenizer", diff --git a/src/ZendModuleProvider.php b/src/ZendModuleProvider.php index 38b54a7..b0223d3 100644 --- a/src/ZendModuleProvider.php +++ b/src/ZendModuleProvider.php @@ -22,6 +22,7 @@ use Zend\ModuleManager\Feature\SerializerProviderInterface; use Zend\ModuleManager\Feature\ServiceProviderInterface; use Zend\ModuleManager\Feature\ValidatorProviderInterface; +use Zend\ModuleManager\Feature\ViewHelperProviderInterface; /** * Provide configuration by consuming zend-modulemanager Module classes. @@ -62,6 +63,7 @@ public function __invoke() : array 'hydrators' => $this->getHydratorConfig(), 'input_filters' => $this->getInputFilterConfig(), 'serializers' => $this->getSerializerConfig(), + 'view_helpers' => $this->getViewHelperConfig(), ])); } @@ -177,7 +179,7 @@ public function getHydratorConfig() : array return $this->convert($this->module->getHydratorConfig()); } - public function getInputFilterConfig() + public function getInputFilterConfig() /* : array */ { if (! $this->module instanceof InputFilterProviderInterface) { return []; @@ -194,4 +196,13 @@ public function getSerializerConfig() : array return $this->convert($this->module->getSerializerConfig()); } + + public function getViewHelperConfig() : array + { + if (! $this->module instanceof ViewHelperProviderInterface) { + return []; + } + + return $this->convert($this->module->getViewHelperConfig()); + } } diff --git a/test/ZendModuleProviderTest.php b/test/ZendModuleProviderTest.php index b5a14c5..c5d4acd 100644 --- a/test/ZendModuleProviderTest.php +++ b/test/ZendModuleProviderTest.php @@ -21,6 +21,7 @@ use Zend\ModuleManager\Feature\RouteProviderInterface; use Zend\ModuleManager\Feature\SerializerProviderInterface; use Zend\ModuleManager\Feature\ValidatorProviderInterface; +use Zend\ModuleManager\Feature\ViewHelperProviderInterface; use ZendTest\ConfigAggregatorModuleManager\Resources\ServiceManagerConfigurationTrait; use ZendTest\ConfigAggregatorModuleManager\Resources\ZendModule; use ZendTest\ConfigAggregatorModuleManager\Resources\ZendModuleWithInvalidConfiguration; @@ -148,6 +149,21 @@ public function testCanProvideSerializersFromSerializerProviderInterface() $this->assertSame($this->createServiceManagerConfiguration(), $config['serializers']); } + public function testCanProviderViewHelpersFromViewHelperProviderInterface() + { + $module = $this->createMock(ViewHelperProviderInterface::class); + $module + ->expects($this->once()) + ->method('getViewHelperConfig') + ->willReturn($this->createServiceManagerConfiguration()); + + $provider = new ZendModuleProvider($module); + + $config = $provider(); + $this->assertArrayHasKey('view_helpers', $config); + $this->assertSame($this->createServiceManagerConfiguration(), $config['view_helpers']); + } + public function testCanProvideAnyConfigValue() { $module = new ZendModule(); @@ -191,7 +207,7 @@ public function testCanHandleModulesWithTraversableConfiguration() $this->assertSame($this->createServiceManagerConfiguration(), $config['dependencies']); } - public function testCanHandleModuelsWithZendConfigConfiguration() + public function testCanHandleModulesWithZendConfigConfiguration() { $module = new ZendModuleWithTraversableConfig(); $provider = new ZendModuleProvider($module);