Пример #1
0
 /**
  * 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));
 }
 /**
  * Trigger batch import.
  *
  * Runs on production.
  *
  * @param Batch $batch
  */
 public function import(Batch $batch)
 {
     do_action('sme_import', $batch);
     $message = sprintf('Prepare import on %s (ID: <span id="sme-batch-id">%s</span>)', get_bloginfo('name'), $batch->get_id());
     $this->add_deploy_message($batch->get_id(), $message, 'info', 100);
     $factory = new Batch_Importer_Factory($this, $this->dao_factory);
     $importer = $factory->get_importer($batch);
     $importer->run();
 }