-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathTemplateRendererInterface.php
67 lines (60 loc) · 2.22 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
<?php
/**
* @see https://github.com/zendframework/zend-expressive-template for the canonical source repository
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-expressive-template/blob/master/LICENSE.md New BSD License
*/
declare(strict_types=1);
namespace Zend\Expressive\Template;
/**
* Interface defining required template capabilities.
*/
interface TemplateRendererInterface
{
/**
* @const string Value indicating all templates; used with `addDefaultParam()`.
*/
public const TEMPLATE_ALL = '*';
/**
* Render a template, optionally with parameters.
*
* Implementations MUST support the `namespace::template` naming convention,
* and allow omitting the filename extension.
*
* @param array|object $params
*/
public function render(string $name, $params = []) : string;
/**
* Add a template path to the engine.
*
* Adds a template path, with optional namespace the templates in that path
* provide.
*/
public function addPath(string $path, string $namespace = null) : void;
/**
* Retrieve configured paths from the engine.
*
* @return TemplatePath[]
*/
public function getPaths() : array;
/**
* 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(string $templateName, string $param, $value) : void;
}