This repository has been archived by the owner on Jan 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
TemplateRendererInterface.php
72 lines (66 loc) · 2.26 KB
/
TemplateRendererInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @see https://github.com/zendframework/zend-expressive for the canonical source repository
* @copyright Copyright (c) 2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-expressive/blob/master/LICENSE.md New BSD License
*/
namespace Zend\Expressive\Template;
/**
* Interface defining required template capabilities.
*/
interface TemplateRendererInterface
{
/**
* @const string Value indicating all templates; used with `addDefaultParam()`.
*/
const TEMPLATE_ALL = '*';
/**
* Render a template, optionally with parameters.
*
* Implementations MUST support the `namespace::template` naming convention,
* and allow omitting the filename extension.
*
* @param string $name
* @param array|object $params
* @return string
*/
public function render($name, $params = []);
/**
* Add a template path to the engine.
*
* Adds a template path, with optional namespace the templates in that path
* provide.
*
* @param string $path
* @param string $namespace
*/
public function addPath($path, $namespace = null);
/**
* Retrieve configured paths from the engine.
*
* @return TemplatePath[]
*/
public function getPaths();
/**
* Add a default parameter to use with a template.
*
* Use this method to provide a default parameter to use when a template is
* rendered. The parameter may be overridden by providing it when calling
* `render()`, or by calling this method again with a null value.
*
* The parameter will be specific to the template name provided. To make
* the parameter available to any template, pass the TEMPLATE_ALL constant
* for the template name.
*
* If the default parameter existed previously, subsequent invocations with
* the same template name and parameter name will overwrite.
*
* @param string $templateName Name of template to which the param applies;
* use TEMPLATE_ALL to apply to all templates.
* @param string $param Param name.
* @param mixed $value
*/
public function addDefaultParam($templateName, $param, $value);
}