本文整理汇总了PHP中thebuggenie\core\framework\Context::getCache方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::getCache方法的具体用法?PHP Context::getCache怎么用?PHP Context::getCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thebuggenie\core\framework\Context
的用法示例。
在下文中一共展示了Context::getCache方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
public function initialize()
{
$filename = THEBUGGENIE_PATH . 'i18n' . DS . $this->_language . DS . 'initialize.inc.php';
if (file_exists($filename)) {
Logging::log("Initiating with file '{$filename}", 'i18n');
include $filename;
Logging::log("Done Initiating", 'i18n');
}
if ($this->_strings === null) {
if (Context::getCache()->fileHas(Cache::KEY_I18N . 'strings_' . $this->_language, false)) {
Logging::log('Trying cached strings');
$strings = Context::getCache()->fileGet(Cache::KEY_I18N . 'strings_' . $this->_language, false);
$this->_strings = is_array($strings) ? $strings : null;
}
if ($this->_strings === null) {
Logging::log('No usable cached strings available');
$this->loadStrings();
foreach (array_keys(Context::getModules()) as $module_name) {
$this->loadStrings($module_name);
}
if (is_array($this->_strings)) {
Context::getCache()->fileAdd(Cache::KEY_I18N . 'strings_' . $this->_language, $this->_strings, false);
}
}
}
}
示例2: getIssueRegex
/**
* Returns an array of regular expressions that should be used for matching
* the issue numbers and workflow transitions in a VCS commit.
*
* Each element of an array is a single regular expression that will be
* applied against the incoming commit message. Each regular expression
* should have two named patterns - one denoting the issue number (should
* include prefix if used in project), and one denoting workflow
* transitions.
*
* Simple example would be:
*
* '#fixes issue #(?P<issues>([A-Z0-9]+\-)?\d+) (?P<transitions> \(.*?\))?#i'
*
* @return array
*/
public static function getIssueRegex()
{
// Try getting the regexes from cache first.
if (!($regex = framework\Context::getCache()->get(framework\Cache::KEY_TEXTPARSER_ISSUE_REGEX))) {
// List of keywords that are expected to prefix the issue number in a
// commit message (these are _not_ project prefixes).
$issue_strings = array('bug', 'issue', 'ticket', 'fix', 'fixes', 'fixed', 'fixing', 'applies to', 'closes', 'references', 'ref', 'addresses', 're', 'see', 'according to', 'also see', 'story');
// Add the issue types as prefixes as well.
foreach (\thebuggenie\core\entities\Issuetype::getAll() as $issuetype) {
$issue_strings[] = $issuetype->getName();
}
// Construct the OR'ed (|) regex out of issue prefixes.
$issue_string = join('|', $issue_strings);
$issue_string = html_entity_decode($issue_string, ENT_QUOTES);
$issue_string = str_replace(array(' ', "'"), array('\\s{1,1}', "\\'"), $issue_string);
// Store all regular expressions for mathces in an array.
$regex = array();
// This regex will match messages that contain template like "KEYWORD
// (#)ISSUE_NUMBER (TRANSITIONS)" (parenthesis means optional). For
// example:
// "Resolves issue #2 (Resolve issue)"
$regex[] = '#( |^)(?<!\\!)((' . $issue_string . ')\\s\\#?(?P<issues>([A-Z0-9]+\\-)?\\d+))( \\((?P<transitions>.*?)\\))?#i';
// This regex will match messages that contain template at the beginning
// of message in format "ISSUE_NUMBER: (TRANSITIONS)".
$regex[] = '#^(?<!\\!)((?P<issues>([A-Z0-9]+\\-)?\\d+)):( \\((?P<transitions>.*?)\\))?#i';
// Add the constructed regexes to cache.
framework\Context::getCache()->add(framework\Cache::KEY_TEXTPARSER_ISSUE_REGEX, $regex);
}
// Return the regular expressions.
return $regex;
}
示例3: do_execute
//.........这里部分代码省略.........
$this->cliEcho($db_name . "\n");
$this->cliEcho("\nIf these settings are ok, press ENTER, or anything else to retry: ");
$e_ok = $this->askToDecline();
} while (!$e_ok);
try {
\b2db\Core::setHost($db_hostname);
\b2db\Core::setUname($db_username);
\b2db\Core::setPasswd($db_password);
\b2db\Core::setDBtype($db_type);
\b2db\Core::setTablePrefix('tbg_');
\b2db\Core::doConnect();
\b2db\Core::createDatabase($db_name);
\b2db\Core::setDBname($db_name);
\b2db\Core::doConnect();
} catch (\Exception $e) {
throw new \Exception("Could not connect to the database:\n" . $e->getMessage());
}
\b2db\Core::setDBname($db_name);
$this->cliEcho("\nSuccessfully connected to the database.\n", 'green');
$this->cliEcho("Press ENTER to continue ... ");
$this->pressEnterToContinue();
$this->cliEcho("\n");
$this->cliEcho("Saving database connection information ... ", 'white', 'bold');
$this->cliEcho("\n");
\b2db\Core::saveConnectionParameters($this->_b2db_config_file);
$this->cliEcho("Successfully saved database connection information.\n", 'green');
$this->cliEcho("\n");
} else {
$b2db_config = \Spyc::YAMLLoad($this->_b2db_config_file);
if (!array_key_exists("b2db", $b2db_config)) {
throw new \Exception("Could not find database configuration in file " . $this->_b2db_config_file);
}
try {
\b2db\Core::initialize($b2db_config["b2db"], \thebuggenie\core\framework\Context::getCache());
\b2db\Core::doConnect();
} catch (\Exception $e) {
throw new \Exception("Could not connect to the database:\n" . $e->getMessage() . "\nPlease check your configuration file " . $this->_b2db_config_file);
}
$this->cliEcho("Successfully connected to the database.\n", 'green');
}
$this->cliEcho("\nThe Bug Genie needs some server settings to function properly...\n\n");
do {
$this->cliEcho("URL rewriting\n", 'cyan', 'bold');
$this->cliEcho("The Bug Genie uses a technique called \"url rewriting\" - which allows for pretty\nURLs such as ") . $this->cliEcho('/issue/1', 'white', 'bold') . $this->cliEcho(' instead of ') . $this->cliEcho("viewissue.php?issue_id=1\n", 'white', 'bold');
$this->cliEcho("Make sure you have read the URL_REWRITE document located in the root\nfolder, or at http://www.thebuggenie.com before you continue\n");
if (!$this->hasProvidedArgument('url_subdir')) {
$this->cliEcho("Press ENTER to continue ... ");
$this->pressEnterToContinue();
}
$this->cliEcho("\n");
$this->cliEcho("The Bug Genie subdir\n", 'white', 'bold');
$this->cliEcho("This is the sub-path of the Web server where The Bug Genie will be located.\n");
if ($this->hasProvidedArgument('url_subdir')) {
$this->cliEcho('The Bug Genie subdir: ', 'white', 'bold');
$url_subdir = $this->getProvidedArgument('url_subdir');
$this->cliEcho($url_subdir, 'yellow', 'bold');
$this->cliEcho("\n");
} else {
$this->cliEcho('Start and end this with a forward slash', 'white', 'bold');
$this->cliEcho(". (ex: \"/thebuggenie/\")\nIf The Bug Genie is running at the root directory, just type \"/\" (without the quotes)\n\n");
$this->cliEcho('The Bug Genie subdir: ', 'white', 'bold');
$url_subdir = $this->getInput();
}
$this->cliEcho("\n");
$this->cliEcho("The Bug Genie will now be accessible at\n");
$this->cliEcho("http://example.com" . $url_subdir, 'white', 'bold');
示例4: cache
public function cache()
{
Context::getCache()->fileAdd(Cache::KEY_ROUTES_CACHE, $this->getRoutes());
Context::getCache()->add(Cache::KEY_ROUTES_CACHE, $this->getRoutes());
Context::getCache()->fileAdd(Cache::KEY_COMPONENT_OVERRIDE_MAP_CACHE, $this->getComponentOverrideMap());
Context::getCache()->add(Cache::KEY_COMPONENT_OVERRIDE_MAP_CACHE, $this->getComponentOverrideMap());
Context::getCache()->fileAdd(Cache::KEY_ANNOTATION_LISTENERS_CACHE, $this->getAnnotationListeners());
Context::getCache()->add(Cache::KEY_ANNOTATION_LISTENERS_CACHE, $this->getAnnotationListeners());
}
示例5: saveLinkOrder
public function saveLinkOrder($links)
{
foreach ($links as $key => $link_id) {
$crit = $this->getCriteria();
$crit->addUpdate(self::LINK_ORDER, $key + 1);
$crit->addWhere(self::SCOPE, framework\Context::getScope()->getID());
$this->doUpdateById($crit, $link_id);
}
framework\Context::getCache()->clearCacheKeys(array(framework\Cache::KEY_MAIN_MENU_LINKS));
}
示例6: _postSave
protected function _postSave($is_new)
{
framework\Context::getCache()->delete(framework\Cache::KEY_TEXTPARSER_ISSUE_REGEX);
}