本文整理汇总了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;
}