Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

ViewHelperProviderInterface #3

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if it should be considered as "new feature" or a bugfix.
Also description should be a bit extended, to describe what is the fix/feature.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it is a "new feature" as the view_helpers array key didnt exist in the first place.

It would be a bug if we say "we are handling every method in your module" but actually we just had the features provided by the current ConfigProvider.
I am not sure if its a bugfix as the package never said that it can parse the view_helpers config at all.


### Changed

Expand Down
13 changes: 7 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion src/ZendModuleProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -62,6 +63,7 @@ public function __invoke() : array
'hydrators' => $this->getHydratorConfig(),
'input_filters' => $this->getInputFilterConfig(),
'serializers' => $this->getSerializerConfig(),
'view_helpers' => $this->getViewHelperConfig(),
]));
}

Expand Down Expand Up @@ -177,7 +179,7 @@ public function getHydratorConfig() : array
return $this->convert($this->module->getHydratorConfig());
}

public function getInputFilterConfig()
public function getInputFilterConfig() /* : array */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it help with anything now? Or it is just added because it was missed in that place as 'hard' RTH?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I obviously forgot to add this in the first release.
Therefore I thought adding that comment to remind me that I have to add it in the next major release (as its a bc in case of extending the ConfigProvider. Should have put a final on it since it should be never extended at all...)

{
if (! $this->module instanceof InputFilterProviderInterface) {
return [];
Expand All @@ -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());
}
}
18 changes: 17 additions & 1 deletion test/ZendModuleProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down