|
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\Library, |
|
13
|
|
|
gplcart\core\Module as CoreModule; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Main class for Faker module |
|
17
|
|
|
*/ |
|
18
|
|
|
class Module |
|
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 CoreModule $module |
|
35
|
|
|
* @param Library $library |
|
36
|
|
|
*/ |
|
37
|
|
|
public function __construct(CoreModule $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
|
|
|
|