1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @package Importer |
5
|
|
|
* @author Iurii Makukh |
6
|
|
|
* @copyright Copyright (c) 2017, Iurii Makukh |
7
|
|
|
* @license https://www.gnu.org/licenses/gpl-3.0.en.html GPL-3.0+ |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace gplcart\modules\import; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Main class for Importer module |
14
|
|
|
*/ |
15
|
|
|
class Main |
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Implements hook "route.list" |
20
|
|
|
* @param mixed $routes |
21
|
|
|
*/ |
22
|
|
|
public function hookRouteList(&$routes) |
23
|
|
|
{ |
24
|
|
|
$routes['admin/module/settings/import'] = array( |
25
|
|
|
'access' => 'module_edit', |
26
|
|
|
'handlers' => array( |
27
|
|
|
'controller' => array('gplcart\\modules\\import\\controllers\\Settings', 'editSettings') |
28
|
|
|
) |
29
|
|
|
); |
30
|
|
|
|
31
|
|
|
$routes['admin/tool/import'] = array( |
32
|
|
|
'menu' => array('admin' => /* @text */'Import'), |
33
|
|
|
'access' => 'import_product', |
34
|
|
|
'handlers' => array( |
35
|
|
|
'controller' => array('gplcart\\modules\\import\\controllers\\Import', 'doImport') |
36
|
|
|
) |
37
|
|
|
); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Implements hook "hook.cron" |
42
|
|
|
*/ |
43
|
|
|
public function hookCron() |
44
|
|
|
{ |
45
|
|
|
gplcart_file_empty(gplcart_file_private_module('import'), array('csv'), 24 * 60 * 60); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Implements hook "user.role.permissions" |
50
|
|
|
* @param array $permissions |
51
|
|
|
*/ |
52
|
|
|
public function hookUserRolePermissions(array &$permissions) |
53
|
|
|
{ |
54
|
|
|
$permissions['import_product'] = /* @text */'Importer: import products'; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Implements hook "job.handlers" |
59
|
|
|
* @param mixed $handlers |
60
|
|
|
*/ |
61
|
|
|
public function hookJobHandlers(array &$handlers) |
62
|
|
|
{ |
63
|
|
|
$handlers['import_product'] = array( |
64
|
|
|
'handlers' => array( |
65
|
|
|
'process' => array('gplcart\\modules\\import\\handlers\\Import', 'process') |
66
|
|
|
), |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
} |
71
|
|
|
|