1 | <?php |
||
48 | final class WidgetSetup implements JsonSerializable { |
||
49 | |||
50 | |||
51 | const SIZE_TYPE_MIN = 'min'; |
||
52 | const SIZE_TYPE_MAX = 'max'; |
||
53 | const SIZE_TYPE_DEFAULT = 'default'; |
||
54 | |||
55 | |||
56 | /** @var array */ |
||
57 | private $sizes = []; |
||
58 | |||
59 | /** @var array */ |
||
60 | private $menus = []; |
||
61 | |||
62 | /** @var array */ |
||
63 | private $jobs = []; |
||
64 | |||
65 | /** @var string */ |
||
66 | private $push = ''; |
||
67 | |||
68 | /** @var array */ |
||
69 | private $settings = []; |
||
70 | |||
71 | |||
72 | /** |
||
73 | * Get the defined size for a specific type (min, max, default) |
||
74 | * Returns an array: |
||
75 | * [ |
||
76 | * 'width' => width, |
||
77 | * 'height' => height |
||
78 | * ] |
||
79 | * |
||
80 | * |
||
81 | * @since 15.0.0 |
||
82 | * |
||
83 | * @param string $type |
||
84 | * |
||
85 | * @return array |
||
86 | */ |
||
87 | public function getSize(string $type): array { |
||
94 | |||
95 | /** |
||
96 | * Returns all sizes defined for the widget. |
||
97 | * |
||
98 | * @since 15.0.0 |
||
99 | * |
||
100 | * @return array |
||
101 | */ |
||
102 | public function getSizes(): array { |
||
105 | |||
106 | /** |
||
107 | * Add a new size to the setup. |
||
108 | * |
||
109 | * @since 15.0.0 |
||
110 | * |
||
111 | * @param string $type |
||
112 | * @param int $width |
||
113 | * @param int $height |
||
114 | * |
||
115 | * @return WidgetSetup |
||
116 | */ |
||
117 | public function addSize(string $type, int $width, int $height): WidgetSetup { |
||
125 | |||
126 | /** |
||
127 | * Returns menu entries. |
||
128 | * |
||
129 | * @since 15.0.0 |
||
130 | * |
||
131 | * @return array |
||
132 | */ |
||
133 | public function getMenuEntries(): array { |
||
136 | |||
137 | /** |
||
138 | * Add a menu entry to the widget. |
||
139 | * $function is the Javascript function to be called when clicking the |
||
140 | * menu entry. |
||
141 | * $icon is the css class of the icon. |
||
142 | * $text is the display name of the menu entry. |
||
143 | * |
||
144 | * @since 15.0.0 |
||
145 | * |
||
146 | * @param string $function |
||
147 | * @param string $icon |
||
148 | * @param string $text |
||
149 | * |
||
150 | * @return WidgetSetup |
||
151 | */ |
||
152 | public function addMenuEntry(string $function, string $icon, string $text): WidgetSetup { |
||
161 | |||
162 | |||
163 | /** |
||
164 | * Add a delayed job to the widget. |
||
165 | * |
||
166 | * $function is the Javascript function to be called. |
||
167 | * $delay is the time in seconds between each call. |
||
168 | * |
||
169 | * @since 15.0.0 |
||
170 | * |
||
171 | * @param string $function |
||
172 | * @param int $delay |
||
173 | * |
||
174 | * @return WidgetSetup |
||
175 | */ |
||
176 | public function addDelayedJob(string $function, int $delay): WidgetSetup { |
||
184 | |||
185 | /** |
||
186 | * Get delayed jobs. |
||
187 | * |
||
188 | * @since 15.0.0 |
||
189 | * |
||
190 | * @return array |
||
191 | */ |
||
192 | public function getDelayedJobs(): array { |
||
195 | |||
196 | |||
197 | /** |
||
198 | * Get the push function, called when an event is send to the front-end |
||
199 | * |
||
200 | * @since 15.0.0 |
||
201 | * |
||
202 | * @return string |
||
203 | */ |
||
204 | public function getPush(): string { |
||
207 | |||
208 | /** |
||
209 | * Set the Javascript function to be called when an event is pushed to the |
||
210 | * frontend. |
||
211 | * |
||
212 | * @since 15.0.0 |
||
213 | * |
||
214 | * @param string $function |
||
215 | * |
||
216 | * @return WidgetSetup |
||
217 | */ |
||
218 | public function setPush(string $function): WidgetSetup { |
||
223 | |||
224 | |||
225 | /** |
||
226 | * Returns the default settings for a widget. |
||
227 | * |
||
228 | * @since 15.0.0 |
||
229 | * |
||
230 | * @return array |
||
231 | */ |
||
232 | public function getDefaultSettings(): array { |
||
235 | |||
236 | /** |
||
237 | * Set the default settings for a widget. |
||
238 | * This method is used by the Dashboard app, using the settings created |
||
239 | * using WidgetSetting |
||
240 | * |
||
241 | * @see WidgetSetting |
||
242 | * |
||
243 | * @since 15.0.0 |
||
244 | * |
||
245 | * @param array $settings |
||
246 | * |
||
247 | * @return WidgetSetup |
||
248 | */ |
||
249 | public function setDefaultSettings(array $settings): WidgetSetup { |
||
254 | |||
255 | |||
256 | /** |
||
257 | * @since 15.0.0 |
||
258 | * |
||
259 | * @return array |
||
260 | */ |
||
261 | public function jsonSerialize() { |
||
270 | } |
||
271 | |||
272 |