This repository was archived by the owner on Jan 21, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +35
-5
lines changed Expand file tree Collapse file tree 3 files changed +35
-5
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
/**
3
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)
4
+ * @copyright Copyright (c) 2017-2019 Zend Technologies USA Inc. (https://www.zend.com)
5
5
* @license https://github.com/zendframework/zend-expressive-zendviewrenderer/blob/master/LICENSE.md New BSD License
6
6
*/
7
7
@@ -38,7 +38,7 @@ public function getDependencies() : array
38
38
public function getTemplates () : array
39
39
{
40
40
return [
41
- 'default_suffix ' => 'phtml ' ,
41
+ 'extension ' => 'phtml ' ,
42
42
'layout ' => 'layout::default ' ,
43
43
'paths ' => [],
44
44
];
Original file line number Diff line number Diff line change 1
1
<?php
2
2
/**
3
3
* @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)
5
5
* @license https://github.com/zendframework/zend-expressive-zendviewrenderer/blob/master/LICENSE.md New BSD License
6
6
*/
7
7
@@ -60,6 +60,7 @@ public function __invoke(ContainerInterface $container) : ZendViewRenderer
60
60
$ config = $ container ->has ('config ' ) ? $ container ->get ('config ' ) : [];
61
61
$ config = $ config ['templates ' ] ?? [];
62
62
63
+
63
64
// Configuration
64
65
$ resolver = new Resolver \AggregateResolver ();
65
66
$ resolver ->attach (
@@ -76,8 +77,9 @@ public function __invoke(ContainerInterface $container) : ZendViewRenderer
76
77
// Inject helpers
77
78
$ this ->injectHelpers ($ renderer , $ container );
78
79
80
+ $ defaultSuffix = $ config ['extension ' ] ?? $ config ['default_suffix ' ] ?? null ;
79
81
// Inject renderer
80
- $ view = new ZendViewRenderer ($ renderer , $ config ['layout ' ] ?? null , $ config [ ' default_suffix ' ] ?? null );
82
+ $ view = new ZendViewRenderer ($ renderer , $ config ['layout ' ] ?? null , $ defaultSuffix );
81
83
82
84
// Add template paths
83
85
$ allPaths = isset ($ config ['paths ' ]) && is_array ($ config ['paths ' ]) ? $ config ['paths ' ] : [];
Original file line number Diff line number Diff line change 1
1
<?php
2
2
/**
3
3
* @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)
5
5
* @license https://github.com/zendframework/zend-expressive-zendviewrenderer/blob/master/LICENSE.md New BSD License
6
6
*/
7
7
@@ -253,6 +253,34 @@ public function testConfiguresTemplateMap()
253
253
}
254
254
255
255
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 ()
256
284
{
257
285
$ config = [
258
286
'templates ' => [
You can’t perform that action at this time.
0 commit comments