src/Guzzle/Service/Client.php
protected function executeMultiple($commands)
    {
        $requests = array();
        $commandRequests = new \SplObjectStorage();

        foreach ($commands as $command) {
            $request = $this->prepareCommand($command);
            $commandRequests[$request] = $command;
            $requests[] = $request;
        }

        try {
            $this->send($requests);
            foreach ($commands as $command) {
                $this->dispatch('command.after_send', array('command' => $command));
            }
            return $commands;
        } catch (MultiTransferException $failureException) {
            // Throw a CommandTransferException using the successful and failed commands
            $e = CommandTransferException::fromMultiTransferException($failureException);

            // Remove failed requests from the successful requests array and add to the failures array
            foreach ($failureException->getFailedRequests() as $request) {
                if (isset($commandRequests[$request])) {
                    $e->addFailedCommand($commandRequests[$request]);
                    unset($commandRequests[$request]);
                }
            }

            // Always emit the command after_send events for successful commands
            foreach ($commandRequests as $success) {
                $e->addSuccessfulCommand($commandRequests[$success]);
                $this->dispatch('command.after_send', array('command' => $commandRequests[$success]));
            }

            throw $e;
        }
    }
protected function executeMultiple($commands)
    {
        $requests = array();
        $commandRequests = new \SplObjectStorage();

        foreach ($commands as $command) {
            $request = $this->prepareCommand($command);
            $commandRequests[$request] = $command;
            $requests[] = $request;
        }

        try {
            $this->send($requests);
            foreach ($commands as $command) {
                $this->dispatch('command.after_send', array('command' => $command));
            }
            return $commands;
        } catch (MultiTransferException $failureException) {
            // Throw a CommandTransferException using the successful and failed commands
            $e = CommandTransferException::fromMultiTransferException($failureException);

            // Remove failed requests from the successful requests array and add to the failures array
            foreach ($failureException->getFailedRequests() as $request) {
                if (isset($commandRequests[$request])) {
                    $e->addFailedCommand($commandRequests[$request]);
                    unset($commandRequests[$request]);
                }
            }

            // Always emit the command after_send events for successful commands
            foreach ($commandRequests as $success) {
                $e->addSuccessfulCommand($commandRequests[$success]);
                $this->dispatch('command.after_send', array('command' => $commandRequests[$success]));
            }

            throw $e;
        }
    }
protected function executeMultiple ( $ commands ) { $ requests = array ( ) ; $ commandRequests = new \ SplObjectStorage ( ) ; foreach ( $ commands as $ command ) { $ request = $ this -> prepareCommand ( $ command ) ; $ commandRequests [ $ request ] = $ command ; $ requests [ ] = $ request ; } try { $ this -> send ( $ requests ) ; foreach ( $ commands as $ command ) { $ this -> dispatch ( 'command.after_send' , array ( 'command' => $ command ) ) ; } return $ commands ; } catch ( MultiTransferException $ failureException ) { // Throw a CommandTransferException using the successful and failed commands $ e = CommandTransferException :: fromMultiTransferException ( $ failureException ) ; // Remove failed requests from the successful requests array and add to the failures array foreach ( $ failureException -> getFailedRequests ( ) as $ request ) { if ( isset ( $ commandRequests [ $ request ] ) ) { $ e -> addFailedCommand ( $ commandRequests [ $ request ] ) ; unset ( $ commandRequests [ $ request ] ) ; } } // Always emit the command after_send events for successful commands foreach ( $ commandRequests as $ success ) { $ e -> addSuccessfulCommand ( $ commandRequests [ $ success ] ) ; $ this -> dispatch ( 'command.after_send' , array ( 'command' => $ commandRequests [ $ success ] ) ) ; } throw $ e ; } }
Execute multiple commands in parallel

@param array|Traversable $commands Array of CommandInterface objects to execute

@return array Returns an array of the executed commands
@throws Exception\CommandTransferException
Execute multiple commands in parallel