better check for invalid cli classes
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -48,13 +48,6 @@ $fileIgnoreList = [
|
|||||||
'CliCommand.php',
|
'CliCommand.php',
|
||||||
'index.html',
|
'index.html',
|
||||||
'install.functions.php',
|
'install.functions.php',
|
||||||
// older files not used anymore (should be removed by the updater), but take care of it just in case
|
|
||||||
'Action.php',
|
|
||||||
'CmdLineHandler.php',
|
|
||||||
'ConfigServicesCmd.php',
|
|
||||||
'PhpSessioncleanCmd.php',
|
|
||||||
'SwitchServerIpCmd.php',
|
|
||||||
'UpdateCliCmd.php',
|
|
||||||
];
|
];
|
||||||
// directory of commands to include
|
// directory of commands to include
|
||||||
$cmd_files = glob(Froxlor::getInstallDir() . '/lib/Froxlor/Cli/*.php');
|
$cmd_files = glob(Froxlor::getInstallDir() . '/lib/Froxlor/Cli/*.php');
|
||||||
@@ -68,7 +61,7 @@ foreach ($cmd_files as $cmdFile) {
|
|||||||
// create class-name including namespace
|
// create class-name including namespace
|
||||||
$cmdClass = "\\Froxlor\\Cli\\" . substr(basename($cmdFile), 0, -4);
|
$cmdClass = "\\Froxlor\\Cli\\" . substr(basename($cmdFile), 0, -4);
|
||||||
// check whether it exists
|
// check whether it exists
|
||||||
if (class_exists($cmdClass)) {
|
if (class_exists($cmdClass) && is_subclass_of($cmdClass, '\Froxlor\Cli\CliCommand')) {
|
||||||
// add to cli application
|
// add to cli application
|
||||||
$application->add(new $cmdClass());
|
$application->add(new $cmdClass());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user