Connector.php
public function run($cmd, array $args)
    {
        if (!isset($this->commands[$cmd])) {
            $this->error(sprintf('command %s not exists', $cmd));
        }
        $response = new Response();
        $driverId = isset($args['target']) ? $this->getDriverId($args['target']) : '';
        $driverId = !$driverId && isset($args['targets']) ? $this->getDriverId(current($args['targets'])) : $driverId;
        $interface = $this->getInterfaceByCmd($cmd);
        /*
         * @var string          $name
         * @var DriverInterface $driver
         */
        $data = null;
        foreach ($this->driverList as $name => $driver) {
            if (!$driverId || $driverId == $name) {
                if ($driver instanceof $interface) {
                    if ($driver->mount()) {
                        $data = $this->runCmd($driver, $cmd, $args, $response);
                    }
                    $driver->unmount();
                } else {
                    $this->error(sprintf('command "%s" not supported, please use interface "%s"', $cmd, $interface));
                }
                $this->addDisabledCommand($driver);
                $response->setOptions($driver->getOptions());
            }

            $response->addFile($driver->getRootFileInfo());
        }
        if (!empty($args['init'])) {
            $response->setApi(DriverInterface::VERSION);
        }

        return $data ?: $response;
    }
public function run($cmd, array $args)
    {
        if (!isset($this->commands[$cmd])) {
            $this->error(sprintf('command %s not exists', $cmd));
        }
        $response = new Response();
        $driverId = isset($args['target']) ? $this->getDriverId($args['target']) : '';
        $driverId = !$driverId && isset($args['targets']) ? $this->getDriverId(current($args['targets'])) : $driverId;
        $interface = $this->getInterfaceByCmd($cmd);
        /*
         * @var string          $name
         * @var DriverInterface $driver
         */
        $data = null;
        foreach ($this->driverList as $name => $driver) {
            if (!$driverId || $driverId == $name) {
                if ($driver instanceof $interface) {
                    if ($driver->mount()) {
                        $data = $this->runCmd($driver, $cmd, $args, $response);
                    }
                    $driver->unmount();
                } else {
                    $this->error(sprintf('command "%s" not supported, please use interface "%s"', $cmd, $interface));
                }
                $this->addDisabledCommand($driver);
                $response->setOptions($driver->getOptions());
            }

            $response->addFile($driver->getRootFileInfo());
        }
        if (!empty($args['init'])) {
            $response->setApi(DriverInterface::VERSION);
        }

        return $data ?: $response;
    }
public function run ( $ cmd , array $ args ) { if ( ! isset ( $ this -> commands [ $ cmd ] ) ) { $ this -> error ( sprintf ( 'command %s not exists' , $ cmd ) ) ; } $ response = new Response ( ) ; $ driverId = isset ( $ args [ 'target' ] ) ? $ this -> getDriverId ( $ args [ 'target' ] ) : '' ; $ driverId = ! $ driverId && isset ( $ args [ 'targets' ] ) ? $ this -> getDriverId ( current ( $ args [ 'targets' ] ) ) : $ driverId ; $ interface = $ this -> getInterfaceByCmd ( $ cmd ) ; /*
         * @var string          $name
         * @var DriverInterface $driver
         */ $ data = null ; foreach ( $ this -> driverList as $ name => $ driver ) { if ( ! $ driverId || $ driverId == $ name ) { if ( $ driver instanceof $ interface ) { if ( $ driver -> mount ( ) ) { $ data = $ this -> runCmd ( $ driver , $ cmd , $ args , $ response ) ; } $ driver -> unmount ( ) ; } else { $ this -> error ( sprintf ( 'command "%s" not supported, please use interface "%s"' , $ cmd , $ interface ) ) ; } $ this -> addDisabledCommand ( $ driver ) ; $ response -> setOptions ( $ driver -> getOptions ( ) ) ; } $ response -> addFile ( $ driver -> getRootFileInfo ( ) ) ; } if ( ! empty ( $ args [ 'init' ] ) ) { $ response -> setApi ( DriverInterface :: VERSION ) ; } return $ data ? : $ response ; }
run command.

@param string $cmd
@param array  $args

@return Response|HttpResponse
run command .