public function batchExecute()
    {
        $results = $this->execute(new InvokeSpec($this->units, false))->getResults();

        // Make right order in sequence of results. It's required operation, because JSON-RPC2
        // specification define: "The Response objects being returned from a batch call MAY be returned
        // in any order within the Array. The Client SHOULD match contexts between the set of Request objects and the
        // resulting set of Response objects based on the id member within each Object."

        $callMap = [];
        foreach ($this->units as $index => $unit) {
            /** @var Invoke $unit */
            $callMap[$unit->getRawId()] = $index;
        }

        if (count($results) !== count($this->units)) {
            throw new InvalidResponseException();
        }

        $resultSequence = [];
        foreach ($results as $result) {
            if ($result instanceof Result) {
                /** @var Result $result */
                $resultSequence[ $callMap[$result->getId()] ] = $result->getResult();
            } elseif ($result instanceof Error) {
                /** @var Error $result */
                $resultSequence[ $callMap[$result->getId()] ] = $this->serverErrorMode === self::ERRMODE_EXCEPTION ? $result->getBaseException() : null;
            }
        }
        ksort($resultSequence);
        $this->units = [];

        return $resultSequence;
    }
public function batchExecute()
    {
        $results = $this->execute(new InvokeSpec($this->units, false))->getResults();

        // Make right order in sequence of results. It's required operation, because JSON-RPC2
        // specification define: "The Response objects being returned from a batch call MAY be returned
        // in any order within the Array. The Client SHOULD match contexts between the set of Request objects and the
        // resulting set of Response objects based on the id member within each Object."

        $callMap = [];
        foreach ($this->units as $index => $unit) {
            /** @var Invoke $unit */
            $callMap[$unit->getRawId()] = $index;
        }

        if (count($results) !== count($this->units)) {
            throw new InvalidResponseException();
        }

        $resultSequence = [];
        foreach ($results as $result) {
            if ($result instanceof Result) {
                /** @var Result $result */
                $resultSequence[ $callMap[$result->getId()] ] = $result->getResult();
            } elseif ($result instanceof Error) {
                /** @var Error $result */
                $resultSequence[ $callMap[$result->getId()] ] = $this->serverErrorMode === self::ERRMODE_EXCEPTION ? $result->getBaseException() : null;
            }
        }
        ksort($resultSequence);
        $this->units = [];

        return $resultSequence;
    }
public function batchExecute ( ) { $ results = $ this -> execute ( new InvokeSpec ( $ this -> units , false ) ) -> getResults ( ) ; // Make right order in sequence of results. It's required operation, because JSON-RPC2 // specification define: "The Response objects being returned from a batch call MAY be returned // in any order within the Array. The Client SHOULD match contexts between the set of Request objects and the // resulting set of Response objects based on the id member within each Object." $ callMap = [ ] ; foreach ( $ this -> units as $ index => $ unit ) { /** @var Invoke $unit */ $ callMap [ $ unit -> getRawId ( ) ] = $ index ; } if ( count ( $ results ) !== count ( $ this -> units ) ) { throw new InvalidResponseException ( ) ; } $ resultSequence = [ ] ; foreach ( $ results as $ result ) { if ( $ result instanceof Result ) { /** @var Result $result */ $ resultSequence [ $ callMap [ $ result -> getId ( ) ] ] = $ result -> getResult ( ) ; } elseif ( $ result instanceof Error ) { /** @var Error $result */ $ resultSequence [ $ callMap [ $ result -> getId ( ) ] ] = $ this -> serverErrorMode === self :: ERRMODE_EXCEPTION ? $ result -> getBaseException ( ) : null ; } } ksort ( $ resultSequence ) ; $ this -> units = [ ] ; return $ resultSequence ; }
Execute batch request

@return array
Execute batch request