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 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 ];
Original file line number Diff line number Diff line change 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 ' ] : [];
Original file line number Diff line number Diff line change 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 ' => [
You can’t perform that action at this time.
0 commit comments