Completed
Push — master ( 3ff1ad...b365ec )
by Iurii
03:09
created

Main::hookLibraryList()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 1
1
<?php
2
3
/**
4
 * @package Faker
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 GNU General Public License 3.0
8
 */
9
10
namespace gplcart\modules\faker;
11
12
use gplcart\core\Module,
13
    gplcart\core\Library;
14
15
/**
16
 * Main class for Faker module
17
 */
18
class Main
19
{
20
21
    /**
22
     * Module class instance
23
     * @var \gplcart\core\Module $module
24
     */
25
    protected $module;
26
27
    /**
28
     * Library class instance
29
     * @var \gplcart\core\Library $library
30
     */
31
    protected $library;
32
33
    /**
34
     * @param Module $module
35
     * @param Library $library
36
     */
37
    public function __construct(Module $module, Library $library)
38
    {
39
        $this->module = $module;
40
        $this->library = $library;
41
    }
42
43
    /**
44
     * Implements hook "library.list"
45
     * @param array $libraries
46
     */
47
    public function hookLibraryList(array &$libraries)
48
    {
49
        $libraries['faker'] = array(
50
            'name' => 'Faker',
51
            'description' => 'Faker is a PHP library that generates fake data for you',
52
            'url' => 'https://github.com/fzaninotto/Faker',
53
            'download' => 'https://github.com/fzaninotto/Faker/archive/v1.6.0.zip',
54
            'type' => 'php',
55
            'version' => '1.6.0',
56
            'module' => 'faker',
57
            'files' => array(
58
                'vendor/autoload.php'
59
            )
60
        );
61
    }
62
63
    /**
64
     * Implements hook "route.list"
65
     * @param mixed $routes
66
     */
67
    public function hookRouteList(&$routes)
68
    {
69
        $routes['admin/tool/faker'] = array(
70
            'menu' => array('admin' => 'Generate fake content'),
71
            'access' => 'module_faker_generate',
72
            'handlers' => array(
73
                'controller' => array('gplcart\\modules\\faker\\controllers\\Generator', 'editGenerator')
74
            )
75
        );
76
    }
77
78
    /**
79
     * Implements hook "user.role.permissions"
80
     * @param array $permissions
81
     */
82
    public function hookUserRolePermissions(array &$permissions)
83
    {
84
        $permissions['module_faker_generate'] = 'Faker: generate content';
85
    }
86
87
    /**
88
     * Implements hook "module.enable.after"
89
     */
90
    public function hookModuleEnableAfter()
91
    {
92
        $this->library->clearCache();
93
    }
94
95
    /**
96
     * Implements hook "module.disable.after"
97
     */
98
    public function hookModuleDisableAfter()
99
    {
100
        $this->library->clearCache();
101
    }
102
103
    /**
104
     * Implements hook "module.install.after"
105
     */
106
    public function hookModuleInstallAfter()
107
    {
108
        $this->library->clearCache();
109
    }
110
111
    /**
112
     * Implements hook "module.uninstall.after"
113
     */
114
    public function hookModuleUninstallAfter()
115
    {
116
        $this->library->clearCache();
117
    }
118
119
}
120