本文整理汇总了PHP中UUID::get方法的典型用法代码示例。如果您正苦于以下问题:PHP UUID::get方法的具体用法?PHP UUID::get怎么用?PHP UUID::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UUID
的用法示例。
在下文中一共展示了UUID::get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_ajax_update
public function action_ajax_update($handler)
{
$users = Users::get();
$payload = $handler->handler_vars->raw('payload');
$decoded_payload = json_decode($payload);
if (isset($decoded_payload)) {
// Invalid decoded JSON is NULL.
$commit_sha = $decoded_payload->after;
$owner = isset($decoded_payload->repository->organization) ? $decoded_payload->repository->organization : $decoded_payload->repository->owner->name;
$repo_URL = $decoded_payload->repository->url;
$tree_URL = "https://api.github.com/repos/" . $owner . "/" . $decoded_payload->repository->name . "/git/trees/{$commit_sha}";
$decoded_tree = json_decode(file_get_contents($tree_URL, 0, null, null));
$xml_urls = array_map(function ($a) {
if (strpos($a->path, ".plugin.xml") !== false || $a->path === 'theme.xml') {
return $a->url;
// path was just the filename, url is the API endpoint for the file itself
}
}, $decoded_tree->tree);
$xml_urls = array_filter($xml_urls);
// remove NULLs
if (count($xml_urls) === 1) {
$xml_URL = array_pop($xml_urls);
$decoded_blob = json_decode(file_get_contents($xml_URL, 0, null, null));
if ($decoded_blob->encoding === 'base64') {
$xml_data = base64_decode($decoded_blob->content);
} else {
if ($decoded_blob->encoding === 'utf-8') {
// does it need to be decoded?
} else {
// there's an invalid encoding.
return;
}
}
$xml_object = simplexml_load_string($xml_data, 'SimpleXMLElement');
/* can't hurt to hold onto these */
$xml_object->addChild("xml_string", $xml_object->asXML());
/* won't always need these */
$xml_object->addChild("tree_url", $tree_URL);
$xml_object->addChild("blob_url", $xml_URL);
$xml_object->addChild("ping_contents", $payload);
/* might need this. Or should it go in downloadurl? */
$xml_object->addChild("repo_url", $repo_URL);
/* need to check if there's already a posts with this guid */
if (!isset($xml_object->guid) || trim($xml_object->guid) == '') {
// You must have a GUID or we can't find your plugin...
// @todo Send the owner an error message/file an issue on the repo
$this->file_issue($owner, $decoded_payload->repository->name, 'Info XML needs a GUID', "Habari addons require a GUID to be listed in the Addons Directory.<br>Please create and add a GUID to your xml file. You can use this one, which is new:<br><b>" . UUID::get() . "</b>");
} else {
EventLog::log(_t('Making post for GUID %s', array(trim($xml_object->guid))), 'info');
self::make_post_from_XML($xml_object);
}
} else {
// Wrong number of xml files.
$this->file_issue($owner, $decoded_payload->repository->name, 'Too many XML files', "Habari addons should have a single XML file containing addon information.<br>");
}
} else {
// Something has gone wrong with the json_decode. Do nothing, since there is nothing that can really be done.
}
}
示例2: action_auth_ajax_generate_guid
/**
* Provide a quick AJAX method to return a GUID for the post page.
*
* @param ActionHandler $handler The handler being executed.
*/
public function action_auth_ajax_generate_guid($handler)
{
echo UUID::get();
}
示例3: create
/**
* Create a new session - that is, generate an ID and set the session cookie
*/
public static function create()
{
self::$session_id = UUID::get();
self::cookie(self::$session_id);
}
示例4: test_preset_override
/**
* Test to make sure that a parameter in a preset can be overridden
* Issue habari/habari#355
*/
public function test_preset_override()
{
$preset_name = UUID::get();
Plugins::register(function ($presets) use($preset_name) {
$presets[$preset_name] = array('content_type' => 1);
return $presets;
}, 'filter', 'posts_get_all_presets');
$q1 = Posts::get($preset_name);
$expected1 = array('preset' => array(0 => $preset_name), 'content_type' => 1);
$this->assert_associative_equal($q1->get_param_cache, $expected1, "The parameters defined for the preset aren't the same as those returned by the preset", array($q1->get_param_cache, $expected1));
$q2 = Posts::get(array('preset' => $preset_name, 'content_type' => 2, 'status' => 'published'));
$expected2 = array('status' => 'published', 'content_type' => 2, 'preset' => array(0 => $preset_name));
$this->assert_associative_equal($q2->get_param_cache, $expected2, "The parameters provided to Posts::get() aren't the same as those returned", array($q2->get_param_cache, $expected2));
}
示例5: test_get
public function test_get()
{
// @TODO: figure out if there's a way to make this less dependent on randomness
$this->assert_not_equal($this->uuid->get_hex(), UUID::get());
}
示例6: Generate
public static function Generate()
{
$uuid = new UUID();
return $uuid->get();
}