Skip to content

Commit 024d293

Browse files
committed
1 parent 17f3733 commit 024d293

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

src/Ubiquity/devtools/cmd/Command.php

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -560,16 +560,18 @@ protected static function getCustomCommandInfos() {
560560
}
561561

562562
public static function getCustomCommands() {
563-
if (! isset(self::$customCommands)) {
564-
$classes = UIntrospection::getChildClasses('\\Ubiquity\\devtools\\cmd\\commands\\AbstractCustomCommand');
565-
foreach ($classes as $class) {
566-
$o = new $class();
567-
$cmd = $o->getCommand();
568-
self::$customCommands[$cmd->getName()] = $o;
569-
$aliases = $cmd->getAliases();
570-
if (is_array($aliases)) {
571-
foreach ($aliases as $alias) {
572-
self::$customAliases[$alias] = $o;
563+
if (\class_exists(\Ubiquity\utils\base\UIntrospection::class)) {
564+
if (! isset(self::$customCommands)) {
565+
$classes = UIntrospection::getChildClasses('\\Ubiquity\\devtools\\cmd\\commands\\AbstractCustomCommand');
566+
foreach ($classes as $class) {
567+
$o = new $class();
568+
$cmd = $o->getCommand();
569+
self::$customCommands[$cmd->getName()] = $o;
570+
$aliases = $cmd->getAliases();
571+
if (is_array($aliases)) {
572+
foreach ($aliases as $alias) {
573+
self::$customAliases[$alias] = $o;
574+
}
573575
}
574576
}
575577
}
@@ -578,21 +580,25 @@ public static function getCustomCommands() {
578580
}
579581

580582
public static function reloadCustomCommands(array $config = []) {
581-
self::$customCommands = null;
582-
self::$customAliases = [];
583-
self::preloadCustomCommands($config);
584-
self::getCustomCommands();
583+
if (\class_exists(\Ubiquity\utils\base\UIntrospection::class)) {
584+
self::$customCommands = null;
585+
self::$customAliases = [];
586+
self::preloadCustomCommands($config);
587+
self::getCustomCommands();
588+
}
585589
}
586590

587591
public static function getCustomAliases() {
588592
return self::$customAliases;
589593
}
590594

591595
public static function preloadCustomCommands(array $config = []) {
592-
$config['cmd-pattern'] ??= 'commands' . \DS . '*.cmd.php';
593-
$files = UFileSystem::glob_recursive($config['cmd-pattern']);
594-
foreach ($files as $file) {
595-
include_once $file;
596+
if (\class_exists(\Ubiquity\utils\base\UIntrospection::class)) {
597+
$config['cmd-pattern'] ??= 'commands' . \DS . '*.cmd.php';
598+
$files = UFileSystem::glob_recursive($config['cmd-pattern']);
599+
foreach ($files as $file) {
600+
include_once $file;
601+
}
596602
}
597603
}
598604

0 commit comments

Comments
 (0)