当前位置: 首页>>代码示例>>PHP>>正文


PHP Workflow::checkUpdate方法代码示例

本文整理汇总了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();
 }
开发者ID:rfoxfa,项目名称:local-files,代码行数:60,代码来源:search.php

示例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();
 }
开发者ID:regedor,项目名称:alfred-github-workflow,代码行数:50,代码来源:search.php

示例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], '@');
开发者ID:jesseflorig,项目名称:config,代码行数:31,代码来源:search.php


注:本文中的Workflow::checkUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。