1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Magefix\Magento\Adapter; |
4
|
|
|
use Exception; |
5
|
|
|
use Mage; |
6
|
|
|
/** |
7
|
|
|
* Class MageClass |
8
|
|
|
* @package Magefix\Magento\Adapter |
9
|
|
|
* @author Carlo Tasca <[email protected]> |
10
|
|
|
*/ |
11
|
|
|
class MageClass implements Mageable |
12
|
|
|
{ |
13
|
|
|
public function __construct() |
14
|
|
|
{ |
15
|
|
|
MageApp::init(); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @return string |
20
|
|
|
*/ |
21
|
|
|
public function getVersion() |
22
|
|
|
{ |
23
|
|
|
return Mage::getVersion(); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @return array |
28
|
|
|
*/ |
29
|
|
|
public function getVersionInfo() |
30
|
|
|
{ |
31
|
|
|
return Mage::getVersionInfo(); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @return string |
36
|
|
|
*/ |
37
|
|
|
public function getEdition() |
38
|
|
|
{ |
39
|
|
|
return Mage::getEdition(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param $key |
44
|
|
|
* @param $value |
45
|
|
|
* @param bool $graceful |
46
|
|
|
*/ |
47
|
|
|
public function register($key, $value, $graceful = false) |
48
|
|
|
{ |
49
|
|
|
Mage::register($key, $value, $graceful); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param string $key |
54
|
|
|
* @return mixed |
55
|
|
|
*/ |
56
|
|
|
public function registry($key) |
57
|
|
|
{ |
58
|
|
|
return Mage::registry($key); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param string $key |
63
|
|
|
*/ |
64
|
|
|
public function unregister($key) |
65
|
|
|
{ |
66
|
|
|
Mage::unregister($key); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param string $type |
71
|
|
|
* @return string |
72
|
|
|
*/ |
73
|
|
|
public function getBaseDir($type = 'base') |
74
|
|
|
{ |
75
|
|
|
return Mage::getBaseDir($type); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Parameter type can be: |
81
|
|
|
* - etc |
82
|
|
|
* - controllers |
83
|
|
|
* - sql |
84
|
|
|
* - data |
85
|
|
|
* - locale |
86
|
|
|
* @param $type |
87
|
|
|
* @param $moduleName |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
|
|
public function getModuleDir($type, $moduleName) |
91
|
|
|
{ |
92
|
|
|
return Mage::getModuleDir($type, $moduleName); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @param $path |
97
|
|
|
* @param null $store |
98
|
|
|
* @return mixed |
99
|
|
|
*/ |
100
|
|
|
public function getStoreConfig($path, $store = null) |
101
|
|
|
{ |
102
|
|
|
return Mage::getStoreConfig($path, $store); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @param $path |
107
|
|
|
* @param null $store |
108
|
|
|
* @return bool |
109
|
|
|
*/ |
110
|
|
|
public function getStoreConfigFlag($path, $store = null) |
111
|
|
|
{ |
112
|
|
|
return Mage::getStoreConfigFlag($path, $store); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @return \Mage_Core_Model_Config |
117
|
|
|
*/ |
118
|
|
|
public function getConfig() |
119
|
|
|
{ |
120
|
|
|
return Mage::getConfig(); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return \Varien_Event_Collection |
125
|
|
|
*/ |
126
|
|
|
public function getEvents() |
127
|
|
|
{ |
128
|
|
|
return Mage::getEvents(); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @param $name |
133
|
|
|
* @return \Mage_Core_Helper_Abstract |
134
|
|
|
*/ |
135
|
|
|
public function helper($name) |
136
|
|
|
{ |
137
|
|
|
return Mage::helper($name); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @param string $modelClass |
142
|
|
|
* @param array $arguments |
143
|
|
|
* @return false|\Mage_Core_Model_Abstract |
144
|
|
|
*/ |
145
|
|
|
public function getModel($modelClass = '', $arguments = array()) |
146
|
|
|
{ |
147
|
|
|
return Mage::getModel($modelClass, $arguments); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Set all my data to defaults |
152
|
|
|
* |
153
|
|
|
*/ |
154
|
|
|
public function reset() |
155
|
|
|
{ |
156
|
|
|
Mage::reset(); |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Set application root absolute path |
161
|
|
|
* |
162
|
|
|
* @param string $appRoot |
163
|
|
|
* @throws Mage_Core_Exception |
164
|
|
|
*/ |
165
|
|
|
public function setRoot($appRoot = '') |
166
|
|
|
{ |
167
|
|
|
Mage::setRoot($appRoot); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* Retrieve application root absolute path |
172
|
|
|
* |
173
|
|
|
* @return string |
174
|
|
|
*/ |
175
|
|
|
public function getRoot() |
176
|
|
|
{ |
177
|
|
|
return Mage::root(); |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* Varien Objects Cache |
182
|
|
|
* |
183
|
|
|
* @param string $key optional, if specified will load this key |
184
|
|
|
* @return Varien_Object_Cache |
185
|
|
|
*/ |
186
|
|
|
public function objects($key = null) |
187
|
|
|
{ |
188
|
|
|
// TODO: Implement objects() method. |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* Get base URL path by type |
193
|
|
|
* |
194
|
|
|
* @param string $type |
195
|
|
|
* @param null|bool $secure |
196
|
|
|
* @return string |
197
|
|
|
*/ |
198
|
|
|
public function getBaseUrl($type = "link", $secure = null) |
199
|
|
|
{ |
200
|
|
|
// TODO: Implement getBaseUrl() method. |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Generate url by route and parameters |
205
|
|
|
* @param string $route |
206
|
|
|
* @param array $params |
207
|
|
|
* @return string |
208
|
|
|
*/ |
209
|
|
|
public function getUrl($route = '', $params = array()) |
210
|
|
|
{ |
211
|
|
|
// TODO: Implement getUrl() method. |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* Get design package singleton |
216
|
|
|
* |
217
|
|
|
* @return Mage_Core_Model_Design_Package |
218
|
|
|
*/ |
219
|
|
|
public function getDesign() |
220
|
|
|
{ |
221
|
|
|
// TODO: Implement getDesign() method. |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* Add observer to even object |
226
|
|
|
* |
227
|
|
|
* @param string $eventName |
228
|
|
|
* @param callback $callback |
229
|
|
|
* @param array $data |
230
|
|
|
* @param string $observerName |
231
|
|
|
* @return \Varien_Event_Collection |
232
|
|
|
*/ |
233
|
|
|
public function addObserver($eventName, $callback, $data = array(), $observerName = '', $observerClass = '') |
234
|
|
|
{ |
235
|
|
|
// TODO: Implement addObserver() method. |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* Dispatch event |
240
|
|
|
* |
241
|
|
|
* Calls all observer callbacks registered for this event |
242
|
|
|
* and multiple observers matching event name pattern |
243
|
|
|
* |
244
|
|
|
* @param string $name |
245
|
|
|
* @param array $data |
246
|
|
|
* @return Mage_Core_Model_App |
247
|
|
|
*/ |
248
|
|
|
public function dispatchEvent($name, array $data = array()) |
249
|
|
|
{ |
250
|
|
|
// TODO: Implement dispatchEvent() method. |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* Retrieve model object singleton |
255
|
|
|
* |
256
|
|
|
* @param string $modelClass |
257
|
|
|
* @param array $arguments |
258
|
|
|
* @return Mage_Core_Model_Abstract |
259
|
|
|
*/ |
260
|
|
|
public function getSingleton($modelClass = '', array $arguments = array()) |
261
|
|
|
{ |
262
|
|
|
// TODO: Implement getSingleton() method. |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
/** |
266
|
|
|
* Retrieve object of resource model |
267
|
|
|
* |
268
|
|
|
* @param string $modelClass |
269
|
|
|
* @param array $arguments |
270
|
|
|
* @return Object |
271
|
|
|
*/ |
272
|
|
|
public function getResourceModel($modelClass, $arguments = array()) |
273
|
|
|
{ |
274
|
|
|
// TODO: Implement getResourceModel() method. |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
/** |
278
|
|
|
* Retrieve Controller instance by ClassName |
279
|
|
|
* |
280
|
|
|
* @param string $class |
281
|
|
|
* @param Mage_Core_Controller_Request_Http $request |
282
|
|
|
* @param Mage_Core_Controller_Response_Http $response |
283
|
|
|
* @param array $invokeArgs |
284
|
|
|
* @return Mage_Core_Controller_Front_Action |
285
|
|
|
*/ |
286
|
|
|
public function getControllerInstance($class, $request, $response, array $invokeArgs = array()) |
287
|
|
|
{ |
288
|
|
|
// TODO: Implement getControllerInstance() method. |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
/** |
292
|
|
|
* Retrieve resource vodel object singleton |
293
|
|
|
* |
294
|
|
|
* @param string $modelClass |
295
|
|
|
* @param array $arguments |
296
|
|
|
* @return object |
297
|
|
|
*/ |
298
|
|
|
public function getResourceSingleton($modelClass = '', array $arguments = array()) |
299
|
|
|
{ |
300
|
|
|
// TODO: Implement getResourceSingleton() method. |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
/** |
304
|
|
|
* Retrieve resource helper object |
305
|
|
|
* |
306
|
|
|
* @param string $moduleName |
307
|
|
|
* @return Mage_Core_Model_Resource_Helper_Abstract |
308
|
|
|
*/ |
309
|
|
|
public function getResourceHelper($moduleName) |
310
|
|
|
{ |
311
|
|
|
// TODO: Implement getResourceHelper() method. |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
/** |
315
|
|
|
* Return new exception by module to be thrown |
316
|
|
|
* |
317
|
|
|
* @param string $module |
318
|
|
|
* @param string $message |
319
|
|
|
* @param integer $code |
320
|
|
|
* @return Mage_Core_Exception |
321
|
|
|
*/ |
322
|
|
|
public function exception($module = 'Mage_Core', $message = '', $code = 0) |
323
|
|
|
{ |
324
|
|
|
// TODO: Implement exception() method. |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
/** |
328
|
|
|
* Throw Exception |
329
|
|
|
* |
330
|
|
|
* @param string $message |
331
|
|
|
* @param string $messageStorage |
332
|
|
|
* @throws Mage_Core_Exception |
333
|
|
|
*/ |
334
|
|
|
public function throwException($message, $messageStorage = null) |
335
|
|
|
{ |
336
|
|
|
// TODO: Implement throwException() method. |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
/** |
340
|
|
|
* Get initialized application object. |
341
|
|
|
* |
342
|
|
|
* @param string $code |
343
|
|
|
* @param string $type |
344
|
|
|
* @param string|array $options |
345
|
|
|
* @return Mage_Core_Model_App |
346
|
|
|
*/ |
347
|
|
|
public function app($code = '', $type = 'store', $options = array()) |
348
|
|
|
{ |
349
|
|
|
// TODO: Implement app() method. |
350
|
|
|
} |
351
|
|
|
|
352
|
|
|
/** |
353
|
|
|
* @param string $code |
354
|
|
|
* @param string $type |
355
|
|
|
* @param array $options |
356
|
|
|
* @param string|array $modules |
357
|
|
|
*/ |
358
|
|
|
public function init($code = '', $type = 'store', $options = array(), $modules = array()) |
359
|
|
|
{ |
360
|
|
|
// TODO: Implement init() method. |
361
|
|
|
} |
362
|
|
|
|
363
|
|
|
/** |
364
|
|
|
* Front end main entry point |
365
|
|
|
* |
366
|
|
|
* @param string $code |
367
|
|
|
* @param string $type |
368
|
|
|
* @param string|array $options |
369
|
|
|
*/ |
370
|
|
|
public function run($code = '', $type = 'store', $options = array()) |
371
|
|
|
{ |
372
|
|
|
// TODO: Implement run() method. |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
/** |
376
|
|
|
* Retrieve application installation flag |
377
|
|
|
* |
378
|
|
|
* @param string|array $options |
379
|
|
|
* @return bool |
380
|
|
|
*/ |
381
|
|
|
public function isInstalled($options = array()) |
382
|
|
|
{ |
383
|
|
|
// TODO: Implement isInstalled() method. |
384
|
|
|
} |
385
|
|
|
|
386
|
|
|
/** |
387
|
|
|
* log facility |
388
|
|
|
* |
389
|
|
|
* @param string $message |
390
|
|
|
* @param integer $level |
391
|
|
|
* @param string $file |
392
|
|
|
* @param bool $forceLog |
393
|
|
|
*/ |
394
|
|
|
public function log($message, $level = null, $file = '', $forceLog = false) |
395
|
|
|
{ |
396
|
|
|
// TODO: Implement log() method. |
397
|
|
|
} |
398
|
|
|
|
399
|
|
|
/** |
400
|
|
|
* Write exception to log |
401
|
|
|
* |
402
|
|
|
* @param Exception $e |
403
|
|
|
*/ |
404
|
|
|
public function logException(Exception $e) |
405
|
|
|
{ |
406
|
|
|
// TODO: Implement logException() method. |
407
|
|
|
} |
408
|
|
|
|
409
|
|
|
/** |
410
|
|
|
* Set enabled developer mode |
411
|
|
|
* |
412
|
|
|
* @param bool $mode |
413
|
|
|
* @return bool |
414
|
|
|
*/ |
415
|
|
|
public function setIsDeveloperMode($mode) |
416
|
|
|
{ |
417
|
|
|
// TODO: Implement setIsDeveloperMode() method. |
418
|
|
|
} |
419
|
|
|
|
420
|
|
|
/** |
421
|
|
|
* Retrieve enabled developer mode |
422
|
|
|
* |
423
|
|
|
* @return bool |
424
|
|
|
*/ |
425
|
|
|
public function getIsDeveloperMode() |
426
|
|
|
{ |
427
|
|
|
// TODO: Implement getIsDeveloperMode() method. |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
/** |
431
|
|
|
* Display exception |
432
|
|
|
* |
433
|
|
|
* @param Exception $e |
434
|
|
|
*/ |
435
|
|
|
public function printException(Exception $e, $extra = '') |
436
|
|
|
{ |
437
|
|
|
// TODO: Implement printException() method. |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
/** |
441
|
|
|
* Define system folder directory url by virtue of running script directory name |
442
|
|
|
* Try to find requested folder by shifting to domain root directory |
443
|
|
|
* |
444
|
|
|
* @param string $folder |
445
|
|
|
* @param boolean $exitIfNot |
446
|
|
|
* @return string |
447
|
|
|
*/ |
448
|
|
|
public function getScriptSystemUrl($folder, $exitIfNot = false) |
449
|
|
|
{ |
450
|
|
|
// TODO: Implement getScriptSystemUrl() method. |
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
/** |
454
|
|
|
* Set is downloader flag |
455
|
|
|
* |
456
|
|
|
* @param bool $flag |
457
|
|
|
*/ |
458
|
|
|
public function setIsDownloader($flag = true) |
459
|
|
|
{ |
460
|
|
|
// TODO: Implement setIsDownloader() method. |
461
|
|
|
} |
462
|
|
|
} |
463
|
|
|
|