1 | <?php |
||
15 | class InlineWebLibrary implements WebLibraryInterface { |
||
16 | |||
17 | /** |
||
18 | * A custom Html element that will be inserted into the JS scripts into your <head> tag. |
||
19 | * |
||
20 | * @var HtmlElementInterface |
||
21 | */ |
||
22 | protected $jsElement; |
||
23 | |||
24 | /** |
||
25 | * A custom CSS element that will be inserted into the JS scripts into your <head> tag. |
||
26 | * |
||
27 | * @var HtmlElementInterface |
||
28 | */ |
||
29 | protected $cssElement; |
||
30 | |||
31 | /** |
||
32 | * A custom Html element that will be inserted into the additional scripts into your <head> tag. |
||
33 | * The content of this file is displayed BELOW JS and CSS inclusion. |
||
34 | * |
||
35 | * @var HtmlElementInterface |
||
36 | */ |
||
37 | protected $additionalElement; |
||
38 | |||
39 | /** |
||
40 | * |
||
41 | * @param HtmlElementInterface $jsElement A custom Html element that will be inserted into the JS scripts into your <head> tag. |
||
42 | * @param HtmlElementInterface $cssElement A custom CSS element that will be inserted into the JS scripts into your <head> tag. |
||
43 | * @param HtmlElementInterface $additionalElement A custom Html element that will be inserted into the additional scripts into your <head> tag. The content of this file is displayed BELOW JS and CSS inclusion. |
||
44 | */ |
||
45 | public function __construct(HtmlElementInterface $jsElement = null, |
||
52 | |||
53 | |||
54 | |||
55 | /** |
||
56 | * A custom Html element that will be inserted into the JS scripts into your <head> tag. |
||
57 | * |
||
58 | * @param HtmlElementInterface $jsElement |
||
59 | */ |
||
60 | public function setJsElement(HtmlElementInterface $jsElement) { |
||
64 | |||
65 | /** |
||
66 | * A custom CSS element that will be inserted into the JS scripts into your <head> tag. |
||
67 | * @param HtmlElementInterface $cssElement |
||
68 | */ |
||
69 | public function setCssElement(HtmlElementInterface $cssElement) { |
||
73 | |||
74 | /** |
||
75 | * A custom Html element that will be inserted into the additional scripts into your <head> tag. |
||
76 | * The content of this file is displayed BELOW JS and CSS inclusion. |
||
77 | * |
||
78 | * @param HtmlElementInterface $additionalElement |
||
79 | */ |
||
80 | public function setAdditionalElement(HtmlElementInterface $additionalElement) { |
||
84 | |||
85 | /** |
||
86 | * Returns an array of Javascript files to be included for this library. |
||
87 | * |
||
88 | * @return array<string> |
||
89 | */ |
||
90 | public function getJsFiles() { |
||
93 | |||
94 | /** |
||
95 | * Returns an array of CSS files to be included for this library. |
||
96 | * |
||
97 | * @return array<string> |
||
98 | */ |
||
99 | public function getCssFiles() { |
||
102 | |||
103 | /** |
||
104 | * Returns a list of libraries that must be included before this library is included. |
||
105 | * |
||
106 | * @return array<WebLibraryInterface> |
||
107 | */ |
||
108 | public function getDependencies() { |
||
111 | |||
112 | /** |
||
113 | * Returns a list of features provided by this library. |
||
114 | * A feature is typically a string describing what the file contains. |
||
115 | * |
||
116 | * For instance, an object representing the JQuery library would provide the "jquery" feature. |
||
117 | * |
||
118 | * @return array<string> |
||
119 | */ |
||
120 | public function getFeatures() { |
||
123 | |||
124 | /** |
||
125 | * Sets the script outputed in the JS section |
||
126 | * @param string $script |
||
127 | */ |
||
128 | function setJSFromText($script){ |
||
131 | |||
132 | |||
133 | /** |
||
134 | * Sets the script outputed in the JS section |
||
135 | * |
||
136 | * @param string $filename |
||
137 | * @param Scopable $scope |
||
138 | * @param bool $relativeToRootPath |
||
139 | */ |
||
140 | function setJSFromFile($filename, $scope = null, $relativeToRootPath = true){ |
||
143 | |||
144 | /** |
||
145 | * Sets the css outputed in the CSS section |
||
146 | * @param string $css |
||
147 | */ |
||
148 | function setCSSFromText($css){ |
||
151 | |||
152 | /** |
||
153 | * Sets the script outputed in the CSS section |
||
154 | * |
||
155 | * @param string $filename |
||
156 | * @param Scopable $scope |
||
157 | * @param bool $relativeToRootPath |
||
158 | */ |
||
159 | function setCSSFromFile($filename, $scope = null, $relativeToRootPath = true){ |
||
162 | |||
163 | /** |
||
164 | * Sets the additional items outputed below the JS and CSS sections |
||
165 | * @param string $script |
||
166 | */ |
||
167 | function setAdditionalElementFromText($script){ |
||
170 | |||
171 | /** |
||
172 | * Sets the additional items outputed below the JS and CSS sections |
||
173 | * |
||
174 | * @param string $filename |
||
175 | * @param Scopable $scope |
||
176 | * @param bool $relativeToRootPath |
||
177 | */ |
||
178 | function setAdditionalElementFromFile($filename, $scope = null, $relativeToRootPath = true){ |
||
181 | |||
182 | /** |
||
183 | * A custom Html element that will be inserted into the JS scripts into your <head> tag. |
||
184 | * @return the HtmlElementInterface |
||
185 | */ |
||
186 | public function getJsElement() { |
||
189 | |||
190 | /** |
||
191 | * A custom CSS element that will be inserted into the JS scripts into your <head> tag. |
||
192 | * @return the HtmlElementInterface |
||
193 | */ |
||
194 | public function getCssElement() { |
||
197 | |||
198 | /** |
||
199 | * A custom Html element that will be inserted into the additional scripts into your <head> tag. |
||
200 | * The content of this file is displayed BELOW JS and CSS inclusion. |
||
201 | * @return the HtmlElementInterface |
||
202 | */ |
||
203 | public function getAdditionalElement() { |
||
206 | |||
207 | } |
||
208 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.