當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Statement::asVersion方法代碼示例

本文整理匯總了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;
 }
開發者ID:WillSkates,項目名稱:TinCanPHP,代碼行數:32,代碼來源:RemoteLRS.php

示例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;
 }
開發者ID:socialweb,項目名稱:tincan_xapi,代碼行數:21,代碼來源:RemoteLRS.php


注:本文中的Statement::asVersion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。