1 | <?php |
||
2 | /* |
||
3 | * Manager BFW Modules |
||
4 | * |
||
5 | * @created : 2019-05-03 |
||
6 | * @version : 3.0.0 |
||
7 | * @author : bulton-fr <[email protected]> |
||
8 | */ |
||
9 | |||
10 | $cliArgs = getopt( |
||
11 | '', |
||
12 | [ |
||
13 | 'bfw-path:', |
||
14 | 'vendor-path::', |
||
15 | 'action:', |
||
16 | 'reinstall', |
||
17 | 'all', |
||
18 | 'module:' |
||
19 | ] |
||
20 | ); |
||
21 | |||
22 | $bfwPath = realpath(__DIR__.'/../../../../../'); |
||
23 | if (isset($cliArgs['bfw-path'])) { |
||
24 | $bfwPath = realpath($cliArgs['bfw-path']); |
||
25 | } |
||
26 | |||
27 | $vendorPath = $bfwPath.'/vendor'; |
||
28 | if (isset($cliArgs['vendor-path'])) { |
||
29 | $vendorPath = realpath($cliArgs['vendor-path']); |
||
30 | } |
||
31 | |||
32 | if (!file_exists($vendorPath.'/autoload.php')) { |
||
33 | echo "\033[1;31mUnable to load autoload file from $vendorPath/autoload.php\033[0m\n"; |
||
34 | exit; |
||
35 | } |
||
36 | |||
37 | require_once($vendorPath.'/autoload.php'); |
||
38 | use \bultonFr\Utils\Cli\BasicMsg; |
||
39 | |||
40 | $action = null; |
||
41 | if (isset($cliArgs['action'])) { |
||
42 | $action = $cliArgs['action']; |
||
43 | } |
||
44 | |||
45 | $reinstall = false; |
||
46 | if (isset($cliArgs['reinstall'])) { |
||
47 | $reinstall = true; |
||
48 | } |
||
49 | |||
50 | $allModules = false; |
||
51 | if (isset($cliArgs['all'])) { |
||
52 | $allModules = true; |
||
53 | } |
||
54 | |||
55 | $specificModule = ''; |
||
56 | if (isset($cliArgs['module'])) { |
||
57 | $specificModule = $cliArgs['module']; |
||
58 | } |
||
59 | |||
60 | if ($allModules === false && empty($specificModule)) { |
||
61 | $msg = 'A module should be specified if the option for all module is not declared.'; |
||
62 | BasicMsg::displayMsgNL($msg, 'red', 'bold'); |
||
63 | exit; |
||
64 | } elseif ($allModules === true && empty($specificModule) === false) { |
||
65 | $msg = 'A module is specified but the option for all module is also declared.'; |
||
66 | BasicMsg::displayMsgNL($msg, 'red', 'bold'); |
||
67 | exit; |
||
68 | } |
||
69 | |||
70 | $reinstallTxt = $reinstall ? 'Yes' : 'No'; |
||
71 | $allModulesTxt = $allModules ? 'Yes' : 'No'; |
||
72 | $specificModuleTxt = empty($specificModule) ? 'Not declared' : $specificModule; |
||
73 | |||
74 | /* |
||
75 | echo 'BFW Application path : '.$bfwPath."\n"; |
||
76 | echo 'Vendor path : '.$vendorPath."\n"; |
||
77 | echo 'Action todo : '.$action."\n"; |
||
78 | echo 'Reinstall option : '.$reinstallTxt."\n"; |
||
79 | echo 'Work on all modules : '.$allModulesTxt."\n"; |
||
80 | echo 'Work only on the module : '.$specificModuleTxt."\n"; |
||
81 | //*/ |
||
82 | |||
83 | $app = \BFW\Install\Application::getInstance(); |
||
84 | $app->initSystems([ |
||
85 | 'rootDir' => $bfwPath, |
||
86 | 'vendorDir' => $vendorPath, |
||
87 | 'runSession' => false |
||
88 | ]); |
||
89 | |||
90 | $manager = $app->getModuleManager(); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
91 | $manager |
||
92 | ->setAction($action) |
||
93 | ->setReinstall($reinstall) |
||
94 | ->setAllModules($allModules) |
||
95 | ->setSpecificModule($specificModule) |
||
96 | ; |
||
97 | |||
98 | $app->run(); |
||
99 |