Main   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 70
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A hookUserPermissions() 0 5 1
A hookJobHandlers() 0 8 1
A hookCronRunAfter() 0 4 1
A hookModuleInstallBefore() 0 6 2
A hookRouteList() 0 19 1
1
<?php
2
3
/**
4
 * @package Installer
5
 * @author Iurii Makukh <[email protected]>
6
 * @copyright Copyright (c) 2017, Iurii Makukh <[email protected]>
7
 * @license https://www.gnu.org/licenses/gpl-3.0.en.html GPL-3.0+
8
 */
9
10
namespace gplcart\modules\installer;
11
12
/**
13
 * Main class for Installer module
14
 */
15
class Main
16
{
17
18
    /**
19
     * Implements hook "module.install.before"
20
     * @param null|string $result
21
     */
22
    public function hookModuleInstallBefore(&$result)
23
    {
24
        if (!class_exists('ZipArchive')) {
25
            $result = gplcart_text('Class ZipArchive does not exist');
26
        }
27
    }
28
29
    /**
30
     * Implements hook "route.list"
31
     * @param array $routes
32
     */
33
    public function hookRouteList(array &$routes)
34
    {
35
        $routes['admin/module/install'] = array(
36
            'menu' => array(
37
                'admin' => 'Install' // @text
38
            ),
39
            'access' => 'module_installer_upload',
40
            'handlers' => array(
41
                'controller' => array('gplcart\\modules\\installer\\controllers\\Upload', 'editUpload')
42
            )
43
        );
44
45
        $routes['admin/module/install/download'] = array(
46
            'access' => 'module_installer_download',
47
            'handlers' => array(
48
                'controller' => array('gplcart\\modules\\installer\\controllers\\Download', 'editDownload')
49
            )
50
        );
51
    }
52
53
    /**
54
     * Implements hook "user.permissions"
55
     * @param array $permissions
56
     */
57
    public function hookUserPermissions(array &$permissions)
58
    {
59
        $permissions['module_installer_upload'] = 'Installer: upload modules'; // @text
60
        $permissions['module_installer_download'] = 'Installer: download modules'; // @text
61
    }
62
63
    /**
64
     * Implements hook "job.handlers"
65
     * @param array $handlers
66
     */
67
    public function hookJobHandlers(array &$handlers)
68
    {
69
        $handlers['installer_download_module'] = array(
70
            'handlers' => array(
71
                'process' => array('gplcart\\modules\\installer\\handlers\\Download', 'process')
72
            ),
73
        );
74
    }
75
76
    /**
77
     * Implements hook "hook.cron"
78
     */
79
    public function hookCronRunAfter()
80
    {
81
        gplcart_file_delete_recursive(gplcart_file_private_module('installer'));
82
    }
83
84
}
85