1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @package Skeleton module |
5
|
|
|
* @author Iurii Makukh <[email protected]> |
6
|
|
|
* @copyright Copyright (c) 2015, Iurii Makukh |
7
|
|
|
* @license https://www.gnu.org/licenses/gpl.html GNU/GPLv3 |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace gplcart\modules\skeleton; |
11
|
|
|
|
12
|
|
|
use gplcart\core\Module; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Main class for Skeleton module |
16
|
|
|
*/ |
17
|
|
|
class Skeleton extends Module |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
public function __construct() |
21
|
|
|
{ |
22
|
|
|
parent::__construct(); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Implements hook "route.list" |
27
|
|
|
* @param array $routes |
28
|
|
|
*/ |
29
|
|
|
public function hookRouteList(array &$routes) |
30
|
|
|
{ |
31
|
|
|
$routes['admin/tool/skeleton'] = array( |
32
|
|
|
'menu' => array('admin' => 'Create module'), |
33
|
|
|
'handlers' => array( |
34
|
|
|
'controller' => array('gplcart\\modules\\skeleton\\controllers\\Skeleton', 'editSkeleton') |
35
|
|
|
) |
36
|
|
|
); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Implements hook "job.handlers" |
41
|
|
|
* @param array $handlers |
42
|
|
|
*/ |
43
|
|
|
public function hookJobHandlers(array &$handlers) |
44
|
|
|
{ |
45
|
|
|
$handlers['skeleton'] = array( |
46
|
|
|
'handlers' => array( |
47
|
|
|
'process' => array('gplcart\\modules\\skeleton\\handlers\\Extract', 'process') |
48
|
|
|
), |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Implements hook "validator.handlers" |
54
|
|
|
* @param array $handlers |
55
|
|
|
*/ |
56
|
|
|
public function hookValidatorHandlers(array &$handlers) |
57
|
|
|
{ |
58
|
|
|
$handlers['skeleton'] = array( |
59
|
|
|
'handlers' => array( |
60
|
|
|
'validate' => array('gplcart\\modules\\skeleton\\handlers\\Validator', 'skeleton') |
61
|
|
|
), |
62
|
|
|
); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Implements hook "cron" |
67
|
|
|
*/ |
68
|
|
|
public function hookCron() |
69
|
|
|
{ |
70
|
|
|
// Automatically delete created files older than 1 day |
71
|
|
|
$lifespan = 86400; |
72
|
|
|
$directory = GC_PRIVATE_DOWNLOAD_DIR . '/skeleton'; |
73
|
|
|
if (is_dir($directory)) { |
74
|
|
|
gplcart_file_delete($directory, array('zip'), $lifespan); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
} |
79
|
|
|
|