本文整理汇总了PHP中DevblocksPlatform::getPluginSetting方法的典型用法代码示例。如果您正苦于以下问题:PHP DevblocksPlatform::getPluginSetting方法的具体用法?PHP DevblocksPlatform::getPluginSetting怎么用?PHP DevblocksPlatform::getPluginSetting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DevblocksPlatform
的用法示例。
在下文中一共展示了DevblocksPlatform::getPluginSetting方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
function run() {
$logger = DevblocksPlatform::getConsoleLog();
$logger->info("[] Syncing Repositories");
if (!extension_loaded("oauth")) {
$logger->err("[] The 'oauth' extension is not loaded. Aborting!");
return false;
}
$timeout = ini_get('max_execution_time');
$runtime = microtime(true);
$issue = Wgm_API::getInstance();
// get config
$token = DevblocksPlatform::getPluginSetting('wgm.issues', 'access_token', '');
$issue->setCredentials($token);
// get last sync repo
$last_sync_repo = $this->getParam('repos.last_repo', '');
// max repos to sync
$max_repos = $this->getParam('max_repos', 100);
// get repos
$repos = $issue->get('user/repos');
$synced = 0;
if($last_sync_repo !== '' && array_key_exists($last_sync_repo, $repos))
$logger->info(sprintf("[] Starting sync from %s/%s", $repos[$last_sync_repo]['user'], $repos[$last_sync_repo]['name']));
foreach($repos as $repo) {
if($last_sync_repo !== '' && $repo['id'] != $last_sync_repo) {
$logger->info(sprintf("[] Skipping repository %s!", $repository));
continue;
}
// does the owner of the repository exist in the DB?
if(null === $user = DAO_User::getByLogin($repo['owner']['login'])) {
$user = $issue->get(sprintf('users/%s', $repo['owner']['login']));
$fields = array(
DAO_User::NUMBER => $user['id'],
DAO_User::LOGIN => $user['login'],
DAO_User::NAME => $user['name'],
DAO_User::EMAIL => $user['email']
);
$user = DAO_User::create($fields);
}
$fields = array(
DAO_Repository::NUMBER => $repo['id'],
DAO_Repository::NAME => $repo['name'],
DAO_Repository::DESCRIPTION => $repo['description'],
DAO_Repository::USER_ID => $user->id,
DAO_Repository::ENABLED => true
);
// does the repo exist in the DB?
if(null === $repository = DAO_Repository::getByNumber($repo['id'])) {
DAO_Repository::create($fields);
} else {
DAO_Repository::update($repository->id, $fields);
}
$synced++;
// check amount of repos synced
if($synced == $max_repos) {
$this->setParam('repos.last_repo', $repo_id);
break 2;
}
}
foreach($repos as $repo) {
// is the repo enabled?
$user = DAO_User::get($repo->user_id);
$repository = sprintf("%s/%s", $user->login, $repo->name);
if($last_sync_repo !== '' && $repo_id != $last_sync_repo) {
$logger->info(sprintf("[] Skipping repository %s!", $repository));
continue;
} elseif(!$repo->enabled) {
$logger->info(sprintf("[] Skipping repository %s since it isn't enabled!", $repository));
continue;
}
}
$logger->info("[] Total Runtime: ".number_format((microtime(true)-$runtime)*1000,2)." ms");
}