1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, https://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2025 |
6
|
|
|
* @package Base |
7
|
|
|
* @subpackage View |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Base\View\Helper; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Common abstract class for all view helper classes. |
16
|
|
|
* |
17
|
|
|
* @method string|array config(string $name = null, string|array $default = null) Returns the config value for the given key |
18
|
|
|
* @method \Aimeos\Base\View\Helper\Iface csrf() Returns the CSRF helper object |
19
|
|
|
* @method string date(string $date) Returns the formatted date |
20
|
|
|
* @method \Aimeos\Base\View\Helper\Iface encoder() Returns the encoder helper object |
21
|
|
|
* @method string formparam(string|array $names) Returns the name for the HTML form parameter |
22
|
|
|
* @method \Aimeos\Base\Mail\Message\Iface mail() Returns the e-mail message object |
23
|
|
|
* @method string number(integer|float|decimal $number, integer $decimals = 2) Returns the formatted number |
24
|
|
|
* @method string|array param(string|null $name, string|array $default) Returns the parameter value |
25
|
|
|
* @method string partial(string $filepath, array $params = [] ) Renders the partial template |
26
|
|
|
* @method \Aimeos\Base\View\Helper\Iface request() Returns the request helper object |
27
|
|
|
* @method string translate(string $domain, string $singular, string $plural = '', integer $number = 1) Returns the translated string or the original one if no translation is available |
28
|
|
|
* @method string url(string|null $target, string|null $controller = null, string|null $action = null, array $params = [], array $trailing = [], array $config = []) Returns the URL assembled from the given arguments |
29
|
|
|
* |
30
|
|
|
* @package Base |
31
|
|
|
* @subpackage View |
32
|
|
|
*/ |
33
|
|
|
abstract class Base |
34
|
|
|
{ |
35
|
|
|
private \Aimeos\Base\View\Iface $view; |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Initializes the view helper classes. |
40
|
|
|
* |
41
|
|
|
* @param \Aimeos\Base\View\Iface $view View instance with registered view helpers |
42
|
|
|
*/ |
43
|
|
|
public function __construct( \Aimeos\Base\View\Iface $view ) |
44
|
|
|
{ |
45
|
|
|
$this->view = $view; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Calls the view helper with the given name and arguments and returns it's output. |
51
|
|
|
* |
52
|
|
|
* @param string $name Name of the view helper |
53
|
|
|
* @param array $args Arguments passed to the view helper |
54
|
|
|
* @return mixed Output depending on the view helper |
55
|
|
|
*/ |
56
|
|
|
public function __call( string $name, array $args ) |
57
|
|
|
{ |
58
|
|
|
return call_user_func_array( array( $this->view, $name ), $args ); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Sets a new view object for changing views afterwards |
64
|
|
|
* |
65
|
|
|
* @param \Aimeos\Base\View\Iface $view View object |
66
|
|
|
* @return \Aimeos\Base\View\Helper\Iface Helper object for method chaining |
67
|
|
|
*/ |
68
|
|
|
public function setView( \Aimeos\Base\View\Iface $view ) : Iface |
69
|
|
|
{ |
70
|
|
|
$this->view = $view; |
71
|
|
|
return $this; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Returns the view object. |
77
|
|
|
* |
78
|
|
|
* @return \Aimeos\Base\View\Iface View object |
79
|
|
|
*/ |
80
|
|
|
protected function view() : \Aimeos\Base\View\Iface |
81
|
|
|
{ |
82
|
|
|
return $this->view; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|