-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.php
57 lines (44 loc) · 1.29 KB
/
Main.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* @package CLI
* @author Iurii Makukh <gplcart.software@gmail.com>
* @copyright Copyright (c) 2018, Iurii Makukh <gplcart.software@gmail.com>
* @license https://www.gnu.org/licenses/gpl-3.0.en.html GPL-3.0+
*/
namespace gplcart\modules\cli;
/**
* Main class for CLI module
*/
class Main
{
/**
* Implements hook "cli.route.list"
* @param mixed $routes
*/
public function hookCliRouteList(array &$routes)
{
$custom = $this->getRoutes();
$routes = array_merge($routes, $custom);
}
/**
* Returns an array of supported command routes
* @return array
*/
public function getRoutes()
{
$list = array();
foreach (glob(__DIR__ . '/config/commands/*.php') as $file) {
$command = pathinfo($file, PATHINFO_FILENAME);
$list[$command] = gplcart_config_get($file);
$method = $command;
$parts = explode('-', $command);
if (count($parts) > 1) {
$method = array_pop($parts);
}
$class_name = implode('', $parts);
$list[$command]['handlers']['controller'] = array(
"gplcart\\modules\\cli\\controllers\\commands\\$class_name", "cmd$method$class_name");
}
return $list;
}
}