本文整理匯總了PHP中Workflow::checkUpdate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Workflow::checkUpdate方法的具體用法?PHP Workflow::checkUpdate怎麽用?PHP Workflow::checkUpdate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Workflow
的用法示例。
在下文中一共展示了Workflow::checkUpdate方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
public static function run($scope, $query)
{
self::$enterprise = 'enterprise' === $scope;
if (' ' !== $query[0]) {
return '';
}
$query = ltrim($query);
self::$query = $query;
self::$parts = $parts = explode(' ', $query);
Workflow::init(self::$enterprise, $query);
if (Workflow::checkUpdate()) {
self::addUpdateCommands();
return Workflow::getItemsAsXml();
}
if (self::$enterprise && !Workflow::getBaseUrl()) {
self::addEnterpriseUrlCommand();
return Workflow::getItemsAsXml();
}
if (!Workflow::getAccessToken() || !(self::$user = Workflow::requestApi('/user'))) {
self::addLoginCommands();
return Workflow::getItemsAsXml();
}
Workflow::stopServer();
$isSystem = isset($query[0]) && $query[0] == '>';
$isMy = 'my' == $parts[0] && isset($parts[1]);
$isUser = isset($query[0]) && $query[0] == '@';
$isRepo = false;
$queryUser = null;
if ($isUser) {
$queryUser = ltrim($parts[0], '@');
} elseif (($pos = strpos($parts[0], '/')) !== false) {
$queryUser = substr($parts[0], 0, $pos);
$isRepo = true;
}
if ($isSystem) {
self::addSystemCommands();
Workflow::sortItems();
} else {
if ($isMy) {
self::addMyCommands();
} elseif ($isUser && isset($parts[1])) {
self::addUserSubCommands($queryUser);
} elseif (!$isUser && $isRepo && isset($parts[1])) {
self::addRepoSubCommands();
} else {
self::addDefaultCommands($isUser, $isRepo, $queryUser);
}
Workflow::sortItems();
if ($query) {
if (!$isUser && $isRepo && isset($parts[1])) {
$repoQuery = substr($query, strlen($parts[0]) + 1);
Workflow::addItem(Item::create()->title("Search '{$parts['0']}' for '{$repoQuery}'")->icon('search')->arg('/' . $parts[0] . '/search?q=' . urlencode($repoQuery))->autocomplete(false), false);
}
$path = $isUser ? $queryUser : 'search?q=' . urlencode($query);
$name = self::$enterprise ? 'GitHub Enterprise' : 'GitHub';
Workflow::addItem(Item::create()->title("Search {$name} for '{$query}'")->icon('search')->arg('/' . $path)->autocomplete(false), false);
}
}
return Workflow::getItemsAsXml();
}
示例2: run
public static function run($query)
{
self::$query = $query;
self::$parts = $parts = explode(' ', $query);
Workflow::init($query);
if (Workflow::checkUpdate()) {
self::addUpdateCommands();
return Workflow::getItemsAsXml();
}
if (!Workflow::getConfig('access_token') || !(self::$user = Workflow::requestGithubApi('/user'))) {
self::addLoginCommands();
return Workflow::getItemsAsXml();
}
Workflow::stopServer();
$isSystem = isset($query[0]) && $query[0] == '>';
$isMy = 'my' == $parts[0] && isset($parts[1]);
$isUser = isset($query[0]) && $query[0] == '@';
$isRepo = false;
$queryUser = null;
if ($isUser) {
$queryUser = ltrim($parts[0], '@');
} elseif (($pos = strpos($parts[0], '/')) !== false) {
$queryUser = substr($parts[0], 0, $pos);
$isRepo = true;
}
if ($isSystem) {
self::addSystemCommands();
Workflow::sortItems();
} else {
if ($isMy) {
self::addMyCommands();
} elseif ($isUser && isset($parts[1])) {
self::addUserSubCommands($queryUser);
} elseif (!$isUser && $isRepo && isset($parts[1])) {
self::addRepoSubCommands();
} else {
self::addDefaultCommands($isUser, $isRepo, $queryUser);
}
Workflow::sortItems();
if ($query) {
if (!$isUser && $isRepo && isset($parts[1])) {
$repoQuery = substr($query, strlen($parts[0]) + 1);
Workflow::addItem(Item::create()->title("Search '{$parts['0']}' for '{$repoQuery}'")->icon('search')->arg('https://github.com/' . $parts[0] . '/search?q=' . urlencode($repoQuery))->autocomplete(false), false);
}
$path = $isUser ? $queryUser : 'search?q=' . urlencode($query);
Workflow::addItem(Item::create()->title("Search GitHub for '{$query}'")->icon('search')->arg('https://github.com/' . $path)->autocomplete(false), false);
}
}
return Workflow::getItemsAsXml();
}
示例3: ltrim
<?php
require 'workflow.php';
$query = ltrim($argv[1]);
$parts = explode(' ', $query);
Workflow::init($query);
if (Workflow::checkUpdate()) {
$cmds = array('update' => 'There is an update for this Alfred workflow', 'deactivate autoupdate' => 'Deactivate auto updating this Alfred Workflow');
foreach ($cmds as $cmd => $desc) {
Workflow::addItem(Item::create()->prefix('gh ')->title('> ' . $cmd)->subtitle($desc)->arg('> ' . str_replace(' ', '-', $cmd))->randomUid(), false);
}
print Workflow::getItemsAsXml();
exit;
}
if (!Workflow::getConfig('user') || !($users = Workflow::requestCacheJson('https://github.com/command_bar/users', 'results')) && !Workflow::requestCache('https://github.com/settings/profile')) {
Workflow::removeConfig('user');
$user = null;
if (count($parts) > 1 && $parts[0] == '>' && $parts[1] == 'login' && isset($parts[2])) {
$user = $parts[2];
}
Workflow::addItem(Item::create()->prefix('gh ')->title('> login ' . $user)->subtitle('Log in to GitHub')->arg('> login ' . $user)->valid((bool) $user, '<user>'));
print Workflow::getItemsAsXml();
return;
}
$isSystem = isset($query[0]) && $query[0] == '>';
$isMy = 'my' == $parts[0] && isset($parts[1]);
$isUser = isset($query[0]) && $query[0] == '@';
$isRepo = false;
$queryUser = null;
if ($isUser) {
$queryUser = ltrim($parts[0], '@');