CLI_Command::command_to_array
Method of the class: CLI_Command{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->command_to_array( $command );
- $command(required)
- .
CLI_Command::command_to_array() CLI Command::command to array code WP-CLI 2.13.0-alpha
private function command_to_array( $command ) {
$dump = [
'name' => $command->get_name(),
'description' => $command->get_shortdesc(),
'longdesc' => $command->get_longdesc(),
'hook' => $command->get_hook(),
];
foreach ( $command->get_subcommands() as $subcommand ) {
$dump['subcommands'][] = $this->command_to_array( $subcommand );
}
if ( empty( $dump['subcommands'] ) ) {
$dump['synopsis'] = (string) $command->get_synopsis();
}
return $dump;
}