WP_CLI\Dispatcher
CommandFactory::create_composite_command()
Create a new Composite command instance.
Method of the class: CommandFactory{}
No Hooks.
Return
null
. Nothing (null).
Usage
$result = CommandFactory::create_composite_command( $parent, $name, $callable );
- $parent(mixed) (required)
- The new command's parent Root or Composite command
- $name(string) (required)
- Represents how the command should be invoked
- $callable(mixed) (required)
- -
CommandFactory::create_composite_command() CommandFactory::create composite command code WP-CLI 2.8.0-alpha
private static function create_composite_command( $parent, $name, $callable ) { $reflection = new ReflectionClass( $callable ); $doc_comment = self::get_doc_comment( $reflection ); if ( ! $doc_comment ) { WP_CLI::debug( null === $doc_comment ? "Failed to get doc comment for {$name}." : "No doc comment for {$name}.", 'commandfactory' ); } $docparser = new DocParser( $doc_comment ); $container = new CompositeCommand( $parent, $name, $docparser ); foreach ( $reflection->getMethods() as $method ) { if ( ! self::is_good_method( $method ) ) { continue; } $class = is_object( $callable ) ? $callable : $reflection->name; $subcommand = self::create_subcommand( $container, false, [ $class, $method->name ], $method ); $subcommand_name = $subcommand->get_name(); $container->add_subcommand( $subcommand_name, $subcommand ); } return $container; }