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


PHP UUID::fromHex方法代碼示例

本文整理匯總了PHP中UUID::fromHex方法的典型用法代碼示例。如果您正苦於以下問題:PHP UUID::fromHex方法的具體用法?PHP UUID::fromHex怎麽用?PHP UUID::fromHex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UUID的用法示例。


在下文中一共展示了UUID::fromHex方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: parsePostList

 private function parsePostList($postList)
 {
     if (!$postList) {
         return null;
     }
     $ret = array();
     foreach (explode('|', $postList) as $id) {
         try {
             $ret[] = Post::newFromId(UUID::fromHex($id));
         } catch (\Exception $ex) {
             $this->dieUsage("There is no post with ID {$id}", 'nosuchpostid');
         }
     }
     return $ret;
 }
開發者ID:moegirlwiki,項目名稱:MW-FlowThread,代碼行數:15,代碼來源:API.php

示例2: doImport

 private function doImport(array $json)
 {
     global $wgTriggerFlowThreadHooks;
     $wgTriggerFlowThreadHooks = false;
     $output = $this->getOutput();
     foreach ($json as $articles) {
         $title = \Title::newFromText($articles->title);
         $count = count($articles->posts);
         $skipped = 0;
         // Skip non-existent title
         if ($title === null || !$title->exists()) {
             $output->addWikiMsg('flowthreadimport-failed', $articles->title, $count);
             continue;
         }
         $titleId = $title->getArticleID();
         foreach ($articles->posts as $postJson) {
             $data = array('id' => UUID::fromHex($postJson->id), 'pageid' => $titleId, 'userid' => $postJson->userid, 'username' => $postJson->username, 'text' => $postJson->text, 'parentid' => $postJson->parentid ? UUID::fromHex($postJson->parentid) : null, 'status' => $postJson->status, 'like' => 0, 'report' => 0);
             $postObject = new Post($data);
             try {
                 $postObject->post();
             } catch (\Exception $ex) {
                 $count--;
                 $skipped++;
             }
         }
         if ($count) {
             $logEntry = new \ManualLogEntry('comments', 'import');
             $logEntry->setPerformer($this->getUser());
             $logEntry->setTarget($title);
             $logEntry->setParameters(array('4::count' => $count));
             $logId = $logEntry->insert();
             $logEntry->publish($logId, 'udp');
             $output->addWikiMsg('flowthreadimport-success', $articles->title, $count);
         }
         if ($skipped) {
             $output->addWikiMsg('flowthreadimport-skipped', $articles->title, $skipped);
         }
     }
 }
開發者ID:nbdd0121,項目名稱:MW-FlowThread,代碼行數:39,代碼來源:Import.php


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