1 | <?php |
||
18 | class FileManager |
||
19 | { |
||
20 | |||
21 | /** |
||
22 | * Config class instance |
||
23 | * @var \gplcart\core\Config $config |
||
24 | */ |
||
25 | protected $config; |
||
26 | |||
27 | /** |
||
28 | * @param Config $config |
||
29 | */ |
||
30 | public function __construct(Config $config) |
||
31 | { |
||
32 | $this->config = $config; |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Implements hook "route.list" |
||
37 | * @param array $routes |
||
38 | */ |
||
39 | public function hookRouteList(array &$routes) |
||
40 | { |
||
41 | $routes['admin/module/settings/file-manager'] = array( |
||
42 | 'access' => 'module_edit', |
||
43 | 'handlers' => array( |
||
44 | 'controller' => array('gplcart\\modules\\file_manager\\controllers\\Settings', 'editSettings') |
||
45 | ) |
||
46 | ); |
||
47 | |||
48 | $routes['admin/tool/file-manager'] = array( |
||
49 | 'access' => 'module_file_manager', |
||
50 | 'menu' => array('admin' => /* @text */'File manager'), |
||
51 | 'handlers' => array( |
||
52 | 'controller' => array('gplcart\\modules\\file_manager\\controllers\\FileManager', 'viewFileManager') |
||
53 | ) |
||
54 | ); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * Implements hook "validator.handlers" |
||
59 | * @param array $handlers |
||
60 | */ |
||
61 | public function hookValidatorHandlers(array &$handlers) |
||
62 | { |
||
63 | foreach (array_keys($this->getModel()->getHandlers()) as $command_id) { |
||
64 | $class = str_replace('_', '', $command_id); |
||
65 | $handlers["file_manager_$command_id"] = array( |
||
66 | 'handlers' => array( |
||
67 | 'validate' => array("gplcart\\modules\\file_manager\\handlers\\validators\\$class", "validate$class") |
||
68 | ), |
||
69 | ); |
||
70 | } |
||
71 | |||
72 | $handlers['file_manager_settings'] = array( |
||
73 | 'handlers' => array( |
||
74 | 'validate' => array('gplcart\\modules\\file_manager\\handlers\\validators\\Settings', 'validateSettings') |
||
75 | ), |
||
76 | ); |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * Implements hook "user.role.permissions" |
||
81 | * @param array $permissions |
||
82 | */ |
||
83 | public function hookUserRolePermissions(array &$permissions) |
||
84 | { |
||
85 | $permissions['module_file_manager'] = $this->getLanguage()->text('File manager: access'); |
||
86 | |||
87 | foreach ($this->getModel()->getHandlers() as $command_id => $command) { |
||
88 | $permissions["module_file_manager_$command_id"] = $this->getLanguage()->text('File manager: perform command @name', array('@name' => $command['name'])); |
||
89 | } |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * Implements hook "module.install.before" |
||
94 | * @param null|string $result |
||
95 | */ |
||
96 | public function hookModuleInstallBefore(&$result) |
||
102 | |||
103 | /** |
||
104 | * Implements hook "module.uninstall.after" |
||
105 | */ |
||
106 | public function hookModuleUninstallAfter() |
||
114 | |||
115 | /** |
||
116 | * Returns Command model instance |
||
117 | * @return \gplcart\modules\file_manager\models\Command |
||
118 | */ |
||
119 | protected function getModel() |
||
123 | |||
124 | /** |
||
125 | * Language model class instance |
||
126 | * @return \gplcart\core\modules\Language |
||
127 | */ |
||
128 | protected function getLanguage() |
||
132 | |||
133 | } |
||
134 |