本文整理汇总了PHP中Batch::updateStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP Batch::updateStatus方法的具体用法?PHP Batch::updateStatus怎么用?PHP Batch::updateStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Batch
的用法示例。
在下文中一共展示了Batch::updateStatus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: batchStatusAction
function batchStatusAction()
{
$this->_helper->viewRenderer->setNoRender();
Zend_Loader::loadClass('Batch');
Zend_Loader::loadClass('Document');
Zend_Loader::loadClass('Geoparser_Edina');
Zend_Loader::loadClass('Geoparser_EdinaBatch');
$batchObj = new Batch();
if (isset($_GET["batchID"])) {
$batchID = $_GET["batchID"];
$batch = $batchObj->getByID($batchID);
} elseif (isset($_GET["parserID"])) {
$parserID = $_GET["parserID"];
$batch = $batchObj->getByParserID($parserID);
$batchID = $batchObj->id;
}
if (!$batch) {
//$this->view->requestURI = $this->_request->getRequestUri();
//return $this->render('404error');
throw new Zend_Controller_Action_Exception('Cannnot find this page: ' . $this->_request->getRequestUri(), 404);
}
$edinaObj = new Geoparser_EdinaBatch();
$edinaObj->prepSettings();
$edinaObj->batchName = $batchObj->parserID;
//name of the batch
$responseJSON = $edinaObj->cacheGetBatch();
//get the status, but use the cache
if (!$edinaObj->HTTPstatusOK) {
$status = "error";
} else {
$status = "ok";
$respObj = Zend_Json::decode($responseJSON);
if (!$edinaObj->cacheUsed) {
//cache was not used to generate the resulse, so we can update the status of the batch and its documents
$batchObj->updateStatus("pending");
if (isset($respObj["Texts"])) {
if (is_array($respObj["Texts"])) {
$docObj = new Document();
$docObj->batchID = $batchID;
foreach ($respObj["Texts"] as $text) {
$resourceID = $text["resource-id"];
$docStatus = $text["status"];
$data = array("parserID" => $resourceID, "status" => $docStatus);
if ($docStatus == "complete") {
$data["pLinks"] = Zend_Json::encode($text["output"]);
}
$docObj->url = $text["src"];
$docObj->updateDataByBatchURL($data);
}
}
}
}
unset($batchObj);
unset($docObj);
$batchObj = new Batch();
$batch = $batchObj->getByID($batchID);
$batch["documents"] = $batchObj->documents;
$batch["edina-resp"] = $respObj;
header('Content-Type: application/json; charset=utf8');
echo Zend_Json::encode($batch);
}
}