WP_CLI\Dispatcher
CommandFactory::create_composite_command
Create a new Composite command instance.
Метод класса: CommandFactory{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$result = CommandFactory::create_composite_command( $parent, $name, $callable );
- $parent(разное) (обязательный)
- The new command's parent Root or Composite command.
- $name(строка) (обязательный)
- Represents how the command should be invoked.
- $callable(разное) (обязательный)
- .
Код CommandFactory::create_composite_command() CommandFactory::create composite command WP-CLI 2.13.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;
}