本文整理匯總了PHP中Statement::asVersion方法的典型用法代碼示例。如果您正苦於以下問題:PHP Statement::asVersion方法的具體用法?PHP Statement::asVersion怎麽用?PHP Statement::asVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Statement
的用法示例。
在下文中一共展示了Statement::asVersion方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: saveStatements
public function saveStatements($statements)
{
$versioned_statements = array();
$attachments_map = array();
foreach ($statements as $i => $st) {
if (!$st instanceof Statement) {
$st = new Statement($st);
$statements[$i] = $st;
}
$versioned_statements[$i] = $st->asVersion($this->version);
if ($st->hasAttachmentsWithContent()) {
foreach ($st->getAttachments() as $attachment) {
if (!isset($attachments_map[$attachment->getSha2()])) {
$attachments_map[$attachment->getSha2()] = $attachment;
}
}
}
}
$requestCfg = array('headers' => array('Content-Type' => 'application/json'), 'content' => json_encode($versioned_statements, JSON_UNESCAPED_SLASHES));
if (!empty($attachments_map)) {
$this->_buildAttachmentContent($requestCfg, array_values($attachments_map));
}
$response = $this->sendRequest('POST', 'statements', $requestCfg);
if ($response->success) {
$parsed_content = json_decode($response->content, true);
foreach ($parsed_content as $i => $stId) {
$statements[$i]->setId($stId);
}
$response->content = $statements;
}
return $response;
}
示例2: saveStatements
public function saveStatements($statements)
{
$versioned_statements = array();
foreach ($statements as $i => $st) {
if (!$st instanceof Statement) {
$st = new Statement($st);
$statements[$i] = $st;
}
$versioned_statements[$i] = $st->asVersion($this->version);
}
$requestCfg = array('headers' => array('Content-Type' => 'application/json'), 'content' => json_encode($versioned_statements, JSON_UNESCAPED_SLASHES));
$response = $this->sendRequest('POST', 'statements', $requestCfg);
if ($response->success) {
$parsed_content = json_decode($response->content, true);
foreach ($parsed_content as $i => $stId) {
$statements[$i]->setId($stId);
}
$response->content = $statements;
}
return $response;
}