PHP Класс Webmozart\Console\Handler\DelegatingHandler
You can register handlers or factory callbacks that create those handlers
with the {@link register()} method:
php
$handler = new DelegatingHandler();
$handler->register('json', new JsonHandler());
$handler->register('xml', function () {
$handler = new XmlHandler();
...
return $handler;
});
The executed handler can be selected with {@link selectHandler()}. You need
to pass the name of the handler or a callback that receives the command,
the console arguments and the I/O as parameters:
php
$handler->selectHandler(function (Command $command, Args $args, IO $io) {
return $args->getOption('format');
});
Run {@link handle()} to execute the selected handler:
php
$handler->handle($command, $args, $io);
Показать файл
Открыть проект
Примеры использования класса
Открытые методы
Описание методов
getRegisteredNames()
публичный Метод
Returns all registered handler names.
public handle ( Args $args, IO $io, Command $command ) |
$args |
Webmozart\Console\Api\Args\Args |
|
$io |
Webmozart\Console\Api\IO\IO |
|
$command |
Webmozart\Console\Api\Command\Command |
|
register()
публичный Метод
Registers a command handler for the given name.
selectHandler()
публичный Метод
Selects the executed handler.
public selectHandler ( string | callback $handler ) |
$handler |
string | callback |
The name of the handler or a callback
that returns the name. The callback
receives the executed {@link Command},
the {@link Args} and the {@link IO} as
arguments. |
unregister()
публичный Метод
Unregisters the command handler for the given name.