/** * Get batch from database and populates it with all its data, e.g. posts * users, metadata etc. included in the batch. * * If $id is not provided an empty Batch object will be returned. * * @param int $id * * @return Batch */ public function get($id = null) { // This is a new batch, no need to populate the batch with any content. if ($id === null) { $batch = new Batch(); $batch->set_status('publish'); return $batch; } return $this->batch_dao->find($id); }
/** * Runs on production when a import status request is received. * * @param array $args * @return string */ public function import_status(array $args) { $this->xmlrpc_client->handle_request($args); $result = $this->xmlrpc_client->get_request_data(); $batch = $this->batch_dao->find(intval($result['batch_id'])); $importer = $this->importer_factory->get_importer($batch); $importer->status(); $response = array('status' => $this->api->get_deploy_status($batch->get_id()), 'messages' => $this->api->get_deploy_messages($batch->get_id())); $response = apply_filters('sme_import_status_response', $response, $batch); // Get status. $status = isset($response['status']) ? $response['status'] : 2; // Get messages. $messages = isset($response['messages']) ? $response['messages'] : array(); // Prepare and return the XML-RPC response data. return $this->xmlrpc_client->prepare_response(array('status' => $status, 'messages' => $messages)); }