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

Commit 1f98518

Browse files
committed
Merge branch 'feature/config-provider' into release-2.0.0
Close #47
2 parents 6b39717 + e3f1374 commit 1f98518

File tree

5 files changed

+101
-2
lines changed

5 files changed

+101
-2
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ All notable changes to this project will be documented in this file, in reverse
1010
adds support for the zend-expressive-template v2 series,
1111
zend-expressive-router v3 series, and zend-expressive-helpers v5 series.
1212

13+
- [#47](https://github.com/zendframework/zend-expressive-zendviewrenderer/pull/47)
14+
adds a `ConfigProvider` class with default service wiring and configuration
15+
for the component. It also updates `composer.json` to add
16+
`extra.zf.config-provider` configuration to notify zend-component-installer
17+
of the shipped `ConfigProvider` class, allowing the plugin to inject the
18+
`ConfigProvider` in your application configuration during initial
19+
installation.
20+
1321
### Changed
1422

1523
- [#37](https://github.com/zendframework/zend-expressive-zendviewrenderer/pull/37)
@@ -319,7 +327,7 @@ First stable release.
319327
- [#11](https://github.com/zendframework/zend-expressive-zendviewrenderer/pull/11)
320328
adds a factory for providing the `HelperPluginManager`, and support in the
321329
`ZendViewRendererFactory` for injecting the `HelperPluginManager` service
322-
(using its FQCN) instead of instantiating one directly.
330+
(using its FQCN) instead of instantiating one directly.
323331
- [#13](https://github.com/zendframework/zend-expressive-zendviewrenderer/pull/13)
324332
adds `zendframework/zend-expressive-helpers` as a dependency, in order to
325333
consume its `UrlHelper` and `ServerUrlHelper` implementations.

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@
5555
"dev-master": "1.4.x-dev",
5656
"dev-develop": "1.5.x-dev",
5757
"dev-release-2.0.0": "2.0.x-dev"
58+
},
59+
"zf": {
60+
"config-provider": "Zend\\Expressive\\ZendView\\ConfigProvider"
5861
}
5962
},
6063
"scripts": {

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ConfigProvider.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-expressive-zendviewrenderer for the canonical source repository
4+
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-expressive-zendviewrenderer/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace Zend\Expressive\ZendView;
11+
12+
use Zend\Expressive\Template\TemplateRendererInterface;
13+
use Zend\View\HelperPluginManager;
14+
15+
class ConfigProvider
16+
{
17+
public function __invoke() : array
18+
{
19+
return [
20+
'dependencies' => $this->getDependencies(),
21+
'templates' => $this->getTemplates(),
22+
];
23+
}
24+
25+
public function getDependencies() : array
26+
{
27+
return [
28+
'aliases' => [
29+
TemplateRendererInterface::class => ZendViewRenderer::class,
30+
],
31+
'factories' => [
32+
HelperPluginManager::class => HelperPluginManagerFactory::class,
33+
ZendViewRenderer::class => ZendViewRendererFactory::class,
34+
],
35+
];
36+
}
37+
38+
public function getTemplates() : array
39+
{
40+
return [
41+
'paths' => [],
42+
];
43+
}
44+
}

test/ConfigProviderTest.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-expressive-zendviewrenderer for the canonical source repository
4+
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-expressive-zendviewrenderer/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace ZendTest\Expressive\ZendView;
11+
12+
use PHPUnit\Framework\TestCase;
13+
use Zend\Expressive\ZendView\ConfigProvider;
14+
15+
class ConfigProviderTest extends TestCase
16+
{
17+
/**
18+
* @var ConfigProvider
19+
*/
20+
private $provider;
21+
22+
protected function setUp() : void
23+
{
24+
$this->provider = new ConfigProvider();
25+
}
26+
27+
public function testInvocationReturnsArray() : array
28+
{
29+
$config = ($this->provider)();
30+
self::assertInternalType('array', $config);
31+
32+
return $config;
33+
}
34+
35+
/**
36+
* @depends testInvocationReturnsArray
37+
*/
38+
public function testReturnedArrayContainsDependencies(array $config) : void
39+
{
40+
self::assertArrayHasKey('dependencies', $config);
41+
self::assertArrayHasKey('templates', $config);
42+
self::assertInternalType('array', $config['dependencies']);
43+
}
44+
}

0 commit comments

Comments
 (0)