54 $console->setup($input, $output);
56 $this->console = $console;
57 $this->events = $events;
68 $commands = array_merge($this->getCoreCommands(), $this->getPluginCommands());
69 $commands = $this->events->triggerResults(
'commands',
'cli', [], $commands);
71 foreach ($commands as $command) {
83 return \Elgg\Includer::includeFile($conf);
96 $plugin_commands = $plugin->getStaticConfig(
'cli_commands', []);
97 if (empty($plugin_commands)) {
101 $return = array_merge($return, $plugin_commands);
115 public function add($command) {
116 if (!class_exists($command)) {
120 if (!is_subclass_of($command, BaseCommand::class)) {
124 $command =
new $command();
128 if (!is_subclass_of($command, Command::class)) {
129 $this->console->add($command);
134 $command->addOption(
'as',
'u', InputOption::VALUE_OPTIONAL,
139 $command->addOption(
'language', null, InputOption::VALUE_OPTIONAL,
143 $this->console->add($command);
153 public function run(
bool $bootstrap =
true) {
158 $this->console->run($this->input, $this->output);
elgg_get_release()
Get the current Elgg release.
elgg_get_plugins(string $status= 'active')
Returns an ordered list of plugins.
static elgg()
Get the Elgg codebase path with "/".
getOutput()
Returns console output.
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Wrapper for console application.
__construct(EventsService $events, InputInterface $input, OutputInterface $output)
Constructor.
trait Loggable
Enables adding a logger.
getCoreCommands()
Returns the core cli commands.
getInput()
Returns console input.
getLogger()
Returns logger.
getPluginCommands()
Returns the cli commands registered in plugins.
run(bool $bootstrap=true)
Bootstrap and run console application.
add($command)
Add a new CLI command.
bootstrap()
Add CLI tools to the console application.