当前位置: 首页>>代码示例>>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;未经允许,请勿转载。