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

Commit 1b1811f

Browse files
committed
Merge branch 'feature/67' into develop
Close #67
2 parents 5dd011f + 9b3c532 commit 1b1811f

File tree

4 files changed

+41
-7
lines changed

4 files changed

+41
-7
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ All notable changes to this project will be documented in this file, in reverse
1010

1111
### Changed
1212

13-
- Nothing.
13+
- [#67](https://github.com/zendframework/zend-expressive-zendviewrenderer/pull/67)
14+
changes configuration option for default template suffix used by NamespacedPathStackResolver
15+
to `$config['templates']['extension']` to match other template renderers provided
16+
by framework. Default value is `phtml`
1417

1518
### Deprecated
1619

17-
- Nothing.
20+
- [#67](https://github.com/zendframework/zend-expressive-zendviewrenderer/pull/67)
21+
deprecates configuration option `$config['templates']['default_suffix']`
1822

1923
### Removed
2024

src/ConfigProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* @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)
4+
* @copyright Copyright (c) 2017-2019 Zend Technologies USA Inc. (https://www.zend.com)
55
* @license https://github.com/zendframework/zend-expressive-zendviewrenderer/blob/master/LICENSE.md New BSD License
66
*/
77

@@ -38,7 +38,7 @@ public function getDependencies() : array
3838
public function getTemplates() : array
3939
{
4040
return [
41-
'default_suffix' => 'phtml',
41+
'extension' => 'phtml',
4242
'layout' => 'layout::default',
4343
'paths' => [],
4444
];

src/ZendViewRendererFactory.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* @see https://github.com/zendframework/zend-expressive-zendviewrenderer for the canonical source repository
4-
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (https://www.zend.com)
4+
* @copyright Copyright (c) 2015-2019 Zend Technologies USA Inc. (https://www.zend.com)
55
* @license https://github.com/zendframework/zend-expressive-zendviewrenderer/blob/master/LICENSE.md New BSD License
66
*/
77

@@ -60,6 +60,7 @@ public function __invoke(ContainerInterface $container) : ZendViewRenderer
6060
$config = $container->has('config') ? $container->get('config') : [];
6161
$config = $config['templates'] ?? [];
6262

63+
6364
// Configuration
6465
$resolver = new Resolver\AggregateResolver();
6566
$resolver->attach(
@@ -76,8 +77,9 @@ public function __invoke(ContainerInterface $container) : ZendViewRenderer
7677
// Inject helpers
7778
$this->injectHelpers($renderer, $container);
7879

80+
$defaultSuffix = $config['extension'] ?? $config['default_suffix'] ?? null;
7981
// Inject renderer
80-
$view = new ZendViewRenderer($renderer, $config['layout'] ?? null, $config['default_suffix'] ?? null);
82+
$view = new ZendViewRenderer($renderer, $config['layout'] ?? null, $defaultSuffix);
8183

8284
// Add template paths
8385
$allPaths = isset($config['paths']) && is_array($config['paths']) ? $config['paths'] : [];

test/ZendViewRendererFactoryTest.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* @see https://github.com/zendframework/zend-expressive-zendviewrenderer for the canonical source repository
4-
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (https://www.zend.com)
4+
* @copyright Copyright (c) 2015-2019 Zend Technologies USA Inc. (https://www.zend.com)
55
* @license https://github.com/zendframework/zend-expressive-zendviewrenderer/blob/master/LICENSE.md New BSD License
66
*/
77

@@ -253,6 +253,34 @@ public function testConfiguresTemplateMap()
253253
}
254254

255255
public function testConfiguresCustomDefaultSuffix()
256+
{
257+
$config = [
258+
'templates' => [
259+
'extension' => 'php',
260+
],
261+
];
262+
263+
$this->container->has('config')->willReturn(true);
264+
$this->container->get('config')->willReturn($config);
265+
$this->container->has(HelperPluginManager::class)->willReturn(false);
266+
$this->container->has(PhpRenderer::class)->willReturn(false);
267+
268+
$factory = new ZendViewRendererFactory();
269+
$view = $factory($this->container->reveal());
270+
271+
$r = new ReflectionProperty($view, 'resolver');
272+
$r->setAccessible(true);
273+
$resolver = $r->getValue($view);
274+
275+
$this->assertInstanceOf(
276+
NamespacedPathStackResolver::class,
277+
$resolver,
278+
'Expected NamespacedPathStackResolver not found!'
279+
);
280+
$this->assertEquals('php', $resolver->getDefaultSuffix());
281+
}
282+
283+
public function testConfiguresDeprecatedDefaultSuffix()
256284
{
257285
$config = [
258286
'templates' => [

0 commit comments

Comments
 (0)