Completed
Push — master ( ff890c...757ee3 )
by Iurii
02:12
created

Skeleton::info()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
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