Skip to content

Instantly share code, notes, and snippets.

@inxomnyaa
Created September 12, 2017 23:37
Show Gist options
  • Save inxomnyaa/b2944b2e425b77b4a9feab55e33335a6 to your computer and use it in GitHub Desktop.
Save inxomnyaa/b2944b2e425b77b4a9feab55e33335a6 to your computer and use it in GitHub Desktop.
customui dynamic subcommand overview
private function registerUIs(){
$ui = new SimpleForm($this->getDescription()->getPrefix() . TextFormat::DARK_PURPLE . ' Commands', 'These are all ' . $this->getDescription()->getPrefix() . ' commands:');
$namespace = __NAMESPACE__. '\subcommand\\';
print $namespace;
foreach (\get_declared_classes() as $class){
if (strpos($class, $namespace) === 0){
$c = substr($class, strlen($namespace));
$c = str_replace('SubCommand', '', $c);
if (strlen($c) > 0){
$ui->addButton(new Button(TextFormat::DARK_GREEN . $c));
}
}
}
self::$uis['commands'] = UIAPI::addUI($this, $ui);
/* ********* */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment