1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Generator.php - Code generator interface |
5
|
|
|
* |
6
|
|
|
* Any class generating css or js code must implement this interface. |
7
|
|
|
* |
8
|
|
|
* @package jaxon-core |
|
|
|
|
9
|
|
|
* @author Thierry Feuzeu <[email protected]> |
10
|
|
|
* @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License |
11
|
|
|
* @link https://github.com/jaxon-php/jaxon-core |
12
|
|
|
*/ |
|
|
|
|
13
|
|
|
|
14
|
|
|
namespace Jaxon\Plugin; |
15
|
|
|
|
16
|
|
|
use Jaxon\Utils\Config\Config; |
17
|
|
|
|
18
|
|
|
abstract class Package implements Code\Contracts\Generator |
|
|
|
|
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* The configuration options of the package |
22
|
|
|
* |
23
|
|
|
* @var array |
24
|
|
|
*/ |
25
|
|
|
protected $aOptions = []; |
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* The configuration options of the package |
29
|
|
|
* |
30
|
|
|
* @var Config |
31
|
|
|
*/ |
32
|
|
|
protected $xConfig; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Whether to include the getReadyScript() in the generated code. |
36
|
|
|
* |
37
|
|
|
* @var boolean |
38
|
|
|
*/ |
39
|
|
|
protected $bReadyEnabled = false; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Get package options in an array. |
43
|
|
|
* |
44
|
|
|
* @return array |
45
|
|
|
*/ |
46
|
|
|
public function getOptions() |
|
|
|
|
47
|
|
|
{ |
48
|
|
|
return $this->aOptions; |
49
|
|
|
} |
|
|
|
|
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Get package options in a Config object. |
53
|
|
|
* |
54
|
|
|
* @return Config |
55
|
|
|
*/ |
56
|
|
|
public function getConfig() |
57
|
|
|
{ |
58
|
|
|
return $this->xConfig; |
59
|
|
|
} |
|
|
|
|
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Get the view renderer |
63
|
|
|
* |
64
|
|
|
* @return \Jaxon\Utils\View\Renderer |
65
|
|
|
*/ |
66
|
|
|
public function view() |
67
|
|
|
{ |
68
|
|
|
return jaxon()->view(); |
69
|
|
|
} |
|
|
|
|
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Get the path to the config file |
73
|
|
|
* |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
|
|
abstract public static function getConfigFile(); |
|
|
|
|
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Include the getReadyScript() in the generated code. |
80
|
|
|
* |
81
|
|
|
* @return void |
82
|
|
|
*/ |
83
|
|
|
public function ready() |
84
|
|
|
{ |
85
|
|
|
$this->bReadyEnabled = true; |
86
|
|
|
} |
|
|
|
|
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @inheritDoc |
90
|
|
|
*/ |
|
|
|
|
91
|
|
|
public function readyEnabled() |
92
|
|
|
{ |
93
|
|
|
return $this->bReadyEnabled; |
94
|
|
|
} |
|
|
|
|
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @inheritDoc |
98
|
|
|
*/ |
|
|
|
|
99
|
|
|
public final function readyInlined() |
100
|
|
|
{ |
101
|
|
|
// For packages, the getReadyScript() is never exported to external files. |
102
|
|
|
return true; |
103
|
|
|
} |
|
|
|
|
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @inheritDoc |
107
|
|
|
*/ |
|
|
|
|
108
|
|
|
public final function getHash() |
109
|
|
|
{ |
110
|
|
|
// Packages do not generate hash on their own. So we make this method final. |
111
|
|
|
return ''; |
112
|
|
|
} |
|
|
|
|
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @inheritDoc |
116
|
|
|
*/ |
|
|
|
|
117
|
|
|
public function getCss() |
118
|
|
|
{ |
119
|
|
|
return ''; |
120
|
|
|
} |
|
|
|
|
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @inheritDoc |
124
|
|
|
*/ |
|
|
|
|
125
|
|
|
public function getJs() |
126
|
|
|
{ |
127
|
|
|
return ''; |
128
|
|
|
} |
|
|
|
|
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @inheritDoc |
132
|
|
|
*/ |
|
|
|
|
133
|
|
|
public function getScript() |
134
|
|
|
{ |
135
|
|
|
return ''; |
136
|
|
|
} |
|
|
|
|
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Get the HTML code of the package home page |
140
|
|
|
* |
141
|
|
|
* @return string |
142
|
|
|
*/ |
143
|
|
|
abstract public function getHtml(); |
|
|
|
|
144
|
|
|
} |
145
|
|
|
|