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