Skip to content
13 changes: 12 additions & 1 deletion src/Swoole/Delegators/TCPServerDelegator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Queue\Swoole\Command\GetFailedMessagesCommand;
use Queue\Swoole\Command\GetProcessedMessagesCommand;
use Queue\Swoole\Command\GetQueuedMessagesCommand;
use Queue\Swoole\Exception\RuntimeException;
use Swoole\Server as TCPSwooleServer;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
Expand All @@ -23,6 +24,8 @@
use function array_shift;
use function explode;
use function ltrim;
use function method_exists;
use function sprintf;
use function str_starts_with;
use function trim;

Expand Down Expand Up @@ -63,7 +66,15 @@ public function __invoke(ContainerInterface $container, string $serviceName, cal
$commandClass = $commandMap[$commandName];
$application = new Application();
$commandInstance = $container->get($commandClass);
$application->add($commandInstance);
if (method_exists($application, 'addCommand')) {
$application->addCommand($commandInstance);
} elseif (method_exists($application, 'add')) {
$application->add($commandInstance);
} else {
throw new RuntimeException(
sprintf('%s contains no "add" or "addCommand" method.', $application::class)
);
}
Comment thread
alexmerlin marked this conversation as resolved.

$parsedOptions = [];
foreach ($args as $arg) {
Expand Down