/** * Flush all job batches * * @return void */ protected function flushBatches() { $batches = $this->job->getBatches(); foreach ($batches as $i => $batch) { $url = sprintf('job/%s/batch', $this->job->getId()); $requestEvent = new CreateBatchEvent($this->client->getRestEndpoint() . $url, $batch->asXML()); $this->client->dispatch(Events::CREATE_BATCH, $requestEvent); $response = $this->httpClient->post($url, $batch->asXML()); $response = ResponseMediator::getContent($response); $this->client->dispatch(Events::RESPONSE, new ResponseEvent($requestEvent, $response->asXML())); $batches[$i]->fromXml($response); } }