當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Settings::forceSettingsReload方法代碼示例

本文整理匯總了PHP中thebuggenie\core\framework\Settings::forceSettingsReload方法的典型用法代碼示例。如果您正苦於以下問題:PHP Settings::forceSettingsReload方法的具體用法?PHP Settings::forceSettingsReload怎麽用?PHP Settings::forceSettingsReload使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在thebuggenie\core\framework\Settings的用法示例。


在下文中一共展示了Settings::forceSettingsReload方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: processCommit

 public static function processCommit(\thebuggenie\core\entities\Project $project, $commit_msg, $old_rev, $new_rev, $date = null, $changed, $author, $branch = null, \Closure $callback = null)
 {
     $output = '';
     framework\Context::setCurrentProject($project);
     if ($project->isArchived()) {
         return;
     }
     if (Commits::getTable()->isProjectCommitProcessed($new_rev, $project->getID())) {
         return;
     }
     try {
         framework\Context::getI18n();
     } catch (\Exception $e) {
         framework\Context::reinitializeI18n(null);
     }
     // Is VCS Integration enabled?
     if (framework\Settings::get('vcs_mode_' . $project->getID(), 'vcs_integration') == self::MODE_DISABLED) {
         $output .= '[VCS ' . $project->getKey() . '] This project does not use VCS Integration' . "\n";
         return $output;
     }
     // Parse the commit message, and obtain the issues and transitions for issues.
     $parsed_commit = \thebuggenie\core\entities\Issue::getIssuesFromTextByRegex($commit_msg);
     $issues = $parsed_commit["issues"];
     $transitions = $parsed_commit["transitions"];
     // Build list of affected files
     $file_lines = preg_split('/[\\n\\r]+/', $changed);
     $files = array();
     foreach ($file_lines as $aline) {
         $action = mb_substr($aline, 0, 1);
         if ($action == "A" || $action == "U" || $action == "D" || $action == "M") {
             $theline = trim(mb_substr($aline, 1));
             $files[] = array($action, $theline);
         }
     }
     // Find author of commit, fallback is guest
     /*
      * Some VCSes use a different format of storing the committer's name. Systems like bzr, git and hg use the format
      * Joe Bloggs <me@example.com>, instead of a classic username. Therefore a user will be found via 4 queries:
      * a) First we extract the email if there is one, and find a user with that email
      * b) If one is not found - or if no email was specified, then instead test against the real name (using the name part if there was an email)
      * c) the username or full name is checked against the friendly name field
      * d) and if we still havent found one, then we check against the username
      * e) and if we STILL havent found one, we use the guest user
      */
     // a)
     $user = \thebuggenie\core\entities\tables\Users::getTable()->getByEmail($author);
     if (!$user instanceof \thebuggenie\core\entities\User && preg_match("/(?<=<)(.*)(?=>)/", $author, $matches)) {
         $email = $matches[0];
         // a2)
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByEmail($email);
         if (!$user instanceof \thebuggenie\core\entities\User) {
             // Not found by email
             preg_match("/(?<=^)(.*)(?= <)/", $author, $matches);
             $author = $matches[0];
         }
     }
     // b)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByRealname($author);
     }
     // c)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByBuddyname($author);
     }
     // d)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByUsername($author);
     }
     // e)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = framework\Settings::getDefaultUser();
     }
     framework\Context::setUser($user);
     framework\Settings::forceSettingsReload();
     framework\Context::cacheAllPermissions();
     $output .= '[VCS ' . $project->getKey() . '] Commit to be logged by user ' . $user->getName() . "\n";
     if ($date == null) {
         $date = NOW;
     }
     // Create the commit data
     $commit = new Commit();
     $commit->setAuthor($user);
     $commit->setDate($date);
     $commit->setLog($commit_msg);
     $commit->setPreviousRevision($old_rev);
     $commit->setRevision($new_rev);
     $commit->setProject($project);
     if ($branch !== null) {
         $data = 'branch:' . $branch;
         $commit->setMiscData($data);
     }
     if ($callback !== null) {
         $commit = $callback($commit);
     }
     $commit->save();
     $output .= '[VCS ' . $project->getKey() . '] Commit logged with revision ' . $commit->getRevision() . "\n";
     // Iterate over affected issues and update them.
     foreach ($issues as $issue) {
         $inst = new IssueLink();
         $inst->setIssue($issue);
//.........這裏部分代碼省略.........
開發者ID:AzerothShard,項目名稱:thebuggenie,代碼行數:101,代碼來源:Vcs_integration.php

示例2: setScope

 /**
  * Find and set the current scope
  *
  * @param Scope $scope Specify a scope to set for this request
  */
 public static function setScope($scope = null)
 {
     Logging::log("Setting current scope");
     if ($scope !== null) {
         Logging::log("Setting scope from function parameter");
         self::$_scope = $scope;
         Settings::forceSettingsReload();
         Logging::log("...done (Setting scope from function parameter)");
         return true;
     }
     $row = null;
     try {
         $hostname = null;
         if (!self::isCLI() && !self::isInstallmode()) {
             Logging::log("Checking if scope can be set from hostname (" . $_SERVER['HTTP_HOST'] . ")");
             $hostname = $_SERVER['HTTP_HOST'];
         }
         if (!self::isUpgrademode() && !self::isInstallmode()) {
             $scope = \thebuggenie\core\entities\tables\Scopes::getTable()->getByHostnameOrDefault($hostname);
         }
         if (!$scope instanceof Scope) {
             Logging::log("It couldn't", 'main', Logging::LEVEL_WARNING);
             if (!self::isInstallmode()) {
                 throw new \Exception("The Bug Genie isn't set up to work with this server name.");
             } else {
                 return;
             }
         }
         Logging::log("Setting scope {$scope->getID()} from hostname");
         self::$_scope = $scope;
         Settings::forceSettingsReload();
         Settings::loadSettings();
         Logging::log("...done (Setting scope from hostname)");
         return true;
     } catch (\Exception $e) {
         if (self::isCLI()) {
             Logging::log("Couldn't set up default scope.", 'main', Logging::LEVEL_FATAL);
             throw new \Exception("Could not load default scope. Error message was: " . $e->getMessage());
         } elseif (!self::isInstallmode()) {
             Logging::log("Couldn't find a scope for hostname {$_SERVER['HTTP_HOST']}", 'main', Logging::LEVEL_FATAL);
             Logging::log($e->getMessage(), 'main', Logging::LEVEL_FATAL);
             throw new \Exception("Could not load scope. This is usually because the scopes table doesn't have a scope for this hostname");
         } else {
             Logging::log("Couldn't find a scope for hostname {$_SERVER['HTTP_HOST']}, but we're in installmode so continuing anyway");
         }
     }
 }
開發者ID:JonathanRH,項目名稱:thebuggenie,代碼行數:52,代碼來源:Context.php


注:本文中的thebuggenie\core\framework\Settings::forceSettingsReload方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。