|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @copyright Bluz PHP Team |
|
5
|
|
|
* @link https://github.com/bluzphp/bluzman |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace Bluzman\Generator\Template; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* AbstractTemplate |
|
12
|
|
|
* |
|
13
|
|
|
* @package Bluzman\Generator\Template |
|
14
|
|
|
* |
|
15
|
|
|
* @todo Migrate to Bluz\View\View |
|
16
|
|
|
* @author Pavel Machekhin |
|
17
|
|
|
* @created 2013-03-28 16:36 |
|
18
|
|
|
*/ |
|
19
|
|
|
abstract class AbstractTemplate |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @var string |
|
23
|
|
|
*/ |
|
24
|
|
|
protected $templatePath; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var array |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $templateData = []; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var string |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $filePath; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @return string |
|
38
|
6 |
|
*/ |
|
39
|
|
|
public function getTemplatePath() |
|
40
|
6 |
|
{ |
|
41
|
|
|
return $this->templatePath; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param string $templatePath |
|
46
|
|
|
*/ |
|
47
|
|
|
public function setTemplatePath(string $templatePath) |
|
48
|
|
|
{ |
|
49
|
|
|
$this->templatePath = $templatePath; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @return array |
|
54
|
7 |
|
*/ |
|
55
|
|
|
public function getTemplateData(): array |
|
56
|
7 |
|
{ |
|
57
|
|
|
return array_merge($this->getDefaultTemplateData(), $this->templateData); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @param array $templateData |
|
62
|
6 |
|
*/ |
|
63
|
|
|
public function setTemplateData(array $templateData) |
|
64
|
6 |
|
{ |
|
65
|
6 |
|
$this->templateData = $templateData; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @return string |
|
70
|
6 |
|
*/ |
|
71
|
|
|
public function getFilePath(): string |
|
72
|
6 |
|
{ |
|
73
|
|
|
return $this->filePath; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @param string $filePath |
|
78
|
6 |
|
*/ |
|
79
|
|
|
public function setFilePath(string $filePath) |
|
80
|
6 |
|
{ |
|
81
|
6 |
|
$this->filePath = $filePath; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Get the name of current user |
|
86
|
|
|
* |
|
87
|
|
|
* @return string |
|
88
|
1 |
|
*/ |
|
89
|
|
|
public function getAuthor(): string |
|
90
|
1 |
|
{ |
|
91
|
|
|
return get_current_user(); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @return array |
|
96
|
1 |
|
*/ |
|
97
|
|
|
public function getDefaultTemplateData(): array |
|
98
|
1 |
|
{ |
|
99
|
|
|
$date = new \DateTime(); |
|
100
|
|
|
|
|
101
|
1 |
|
return [ |
|
102
|
1 |
|
'author' => $this->getAuthor(), |
|
103
|
|
|
'date' => $date->format('Y-m-d H:i:s') |
|
104
|
|
|
]; |
|
105
|
|
|
} |
|
106
|
|
|
} |
|
107
|
|
|
|