/** * Deploy a batch from content stage to production. * * Runs on content stage when a deploy request has been received. * * @param Batch $batch * @param bool $auto_import If set to false the batch will be sent to production but the import * will not be triggered. * * @return array */ public function deploy(Batch $batch, $auto_import = true) { /* * Give third-party developers the option to import images before batch * is sent to production. */ do_action('sme_deploy_custom_attachment_importer', $batch->get_attachments(), $batch); /* * Make it possible for third-party developers to alter the list of * attachments to deploy. */ $batch->set_attachments(apply_filters('sme_deploy_attachments', $batch->get_attachments(), $batch)); // Hook in before deploy. do_action('sme_deploy', $batch); // Start building request to send to production. $request = array('batch' => $batch, 'auto_import' => $auto_import); $response = $this->client->request('smeContentStaging.import', $request); // Batch deploy in progress. $response = apply_filters('sme_deploying', $response, $batch); // Get status received from production. $status = isset($response['status']) ? $response['status'] : 1; // Get messages received from production. $messages = isset($response['messages']) ? $response['messages'] : array(); /* * Batch has been deployed and should no longer be accessible by user, * delete it (not actually deleting the batch, just setting it to draft * to make it invisible to users). */ $this->batch_dao->delete_batch($batch); // Return status and messages. return array('status' => $status, 'messages' => $messages); }