本文整理汇总了PHP中Ak::getStaticVar方法的典型用法代码示例。如果您正苦于以下问题:PHP Ak::getStaticVar方法的具体用法?PHP Ak::getStaticVar怎么用?PHP Ak::getStaticVar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ak
的用法示例。
在下文中一共展示了Ak::getStaticVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup
public function setup()
{
foreach (array_keys($this->_singletons) as $singleton) {
$this->_singletons[$singleton] = Ak::getStaticVar($singleton);
Ak::unsetStaticVar($singleton);
}
}
示例2: loadConfig
static function loadConfig($dictionary)
{
static $_loaded = array();
if (!($return = Ak::getStaticVar('AkInflectorConfig::' . $dictionary))) {
$return = Ak::getSettings($dictionary, false);
if ($return !== false) {
Ak::setStaticVar('AkInflectorConfig::' . $dictionary, $return);
$_loaded[$dictionary] = true;
} else {
trigger_error(Ak::t('Could not load inflector rules file: %file', array('%file' => 'config' . DS . $dictionary . '.yml')), E_USER_ERROR);
}
}
return $return;
}
示例3: connect
public function connect($options = null)
{
$this->setOptions($options);
if ($this->_meetsDependencies()) {
$port = $this->getOption('port');
if (!($Connection = Ak::getStaticVar(__CLASS__ . '_' . $this->_connetion_signature))) {
try {
$Connection = new Mongo($this->getOption('host') . (empty($port) ? '' : ':' . $port));
} catch (MongoConnectionException $e) {
$Connection = false;
}
Ak::setStaticVar(__CLASS__ . '_' . $this->_connetion_signature, $Connection);
}
$this->_Mongo[$this->_connetion_signature] = $Connection;
if ($Connection && !$this->isConnected()) {
$Connection->connect();
}
}
return $this->isConnected();
}
示例4: populateTables
function populateTables()
{
$args = func_get_args();
$tables = !empty($args) ? (is_array($args[0]) ? $args[0] : (count($args) > 1 ? $args : Ak::toArray($args))) : array();
foreach ($tables as $table){
$file = AK_TEST_DIR.DS.'fixtures'.DS.'data'.DS.(empty($this->module)?'':$this->module.DS).Ak::sanitize_include($table).'.yaml';
if(!file_exists($file)){
continue;
}
$class_name = AkInflector::classify($table);
if($this->instantiateModel($class_name)){
$contents = &Ak::getStaticVar('yaml_fixture_'.$file);
if (!$contents) {
ob_start();
require_once($file);
$contents = ob_get_clean();
Ak::setStaticVar('yaml_fixture_'.$file, $contents);
}
$items = Ak::convert('yaml','array',$contents);
foreach ($items as $item){
$obj=&$this->{$class_name}->create($item);
if (isset($item['created_at'])) {
$obj->updateAttribute('created_at',$item['created_at']);
} else if (isset($item['created_on'])) {
$obj->updateAttribute('created_on',$item['created_on']);
}
}
}
}
}
示例5: test_static_var_destruct_all_vars
public function test_static_var_destruct_all_vars()
{
$value = new stdClass();
$value->id = 1;
$return = Ak::setStaticVar('testVar1', $value);
$this->assertEqual(true, $return);
$value2 = new stdClass();
$value2->id = 2;
$return = Ak::setStaticVar('testVar2', $value2);
$this->assertEqual(true, $return);
$value3 = new stdClass();
$value3->id = 3;
$return = Ak::setStaticVar('testVar3', $value3);
$this->assertEqual(true, $return);
$null = null;
Ak::unsetStaticVar('testVar1');
$storedValue1 =& Ak::getStaticVar('testVar1');
$this->assertEqual($null, $storedValue1);
$storedValue2 =& Ak::getStaticVar('testVar2');
$this->assertEqual($value2, $storedValue2);
$storedValue3 =& Ak::getStaticVar('testVar3');
$this->assertEqual($value3, $storedValue3);
Ak::unsetStaticVar($null);
$storedValue1 =& Ak::getStaticVar('testVar1');
$this->assertEqual($null, $storedValue1);
$storedValue2 =& Ak::getStaticVar('testVar2');
$this->assertEqual($null, $storedValue2);
$storedValue3 =& Ak::getStaticVar('testVar3');
$this->assertEqual($null, $storedValue3);
}
示例6: makelos_setting
function makelos_setting($settings = array())
{
Ak::getStaticVar('Makelos')->addSettings($settings);
}
示例7: array
/**
* Register the reference to an object object
* @return void
*/
function &getObservers()
{
$staticVarNs='AkActiveRecord::observers::' . $this->_modelName;
$key = 'objects';
$array = array();
$observers_arr =& Ak::getStaticVar($staticVarNs);
if (isset($observers_arr[$key])) {
$observers = &$observers_arr[$key];
} else {
$observers = &$array;
}
return $observers;
}
示例8: array
/**
* Gets the list of observers for the current model.
* @return array
*/
public function &getObservers()
{
$staticVarNs = 'AkActiveModel::observers::' . $this->_Model->getModelName();
$key = 'objects';
$array = array();
$observers_arr = Ak::getStaticVar($staticVarNs);
if (isset($observers_arr[$key])) {
$observers = $observers_arr[$key];
} else {
$observers = $array;
}
return $observers;
}
示例9: isLoaded
/**
* Checks if the user is set
*
* @return boolean
*/
function isLoaded()
{
return Ak::getStaticVar('CurrentUser') != null;
}
示例10: runTaskAsDaemon
public function runTaskAsDaemon($task_name, $options = array())
{
$this->_ensurePosixAndPcntlAreAvailable();
require_once 'System/Daemon.php';
$app_name = AkInflector::underscore($task_name);
$pid_file = AK_BASE_DIR . DS . 'run' . DS . $app_name . DS . $app_name . '.pid';
$log_file = AK_LOG_DIR . DS . 'daemons' . DS . $app_name . '.log';
if (!file_exists($pid_file)) {
if (empty($options['attributes']['kill'])) {
AkFileSystem::file_put_contents($pid_file, '');
AkFileSystem::file_delete($pid_file);
} else {
$this->error("Could not kill process for {$task_name}", true);
}
} else {
$pid = (int) file_get_contents($pid_file);
if ($pid > 0) {
if (!empty($options['attributes']['kill'])) {
$this->message("Killing process {$pid}");
`kill {$pid}`;
AkFileSystem::file_delete($pid_file);
die;
} elseif (!empty($options['attributes']['restart'])) {
$this->message("Restarting {$task_name}.");
$this->message(`kill {$pid}`);
} else {
$this->error("Daemon for {$task_name} still running ({$pid_file}).\nTask aborted.", true);
}
}
}
if (!empty($options['attributes']['kill']) && empty($pid)) {
$this->error("No daemon running for task {$task_name}", true);
}
unset($options['attributes']['restart']);
if (!file_exists($log_file)) {
AkFileSystem::file_put_contents($log_file, '');
}
System_Daemon::setOption('appName', $app_name);
System_Daemon::setOption('appDir', AK_BASE_DIR);
System_Daemon::setOption('logLocation', $log_file);
System_Daemon::setOption('appRunAsUID', posix_geteuid());
System_Daemon::setOption('appRunAsGID', posix_getgid());
System_Daemon::setOption('appPidLocation', $pid_file);
$this->message("Staring daemon. ({$log_file})");
System_Daemon::start();
$dsn = Ak::getStaticVar('dsn');
defined('AK_SKIP_DB_CONNECTION') && AK_SKIP_DB_CONNECTION ? null : Ak::db($dsn);
$this->runTask($task_name, $options);
System_Daemon::stop();
AkFileSystem::file_delete($pid_file);
die;
}
示例11: _getAvailableHelpers
function _getAvailableHelpers()
{
$helpers = array();
if (empty($this->available_helpers)) {
if (defined('AK_SINTAGS_AVALABLE_HELPERS')) {
$helpers = unserialize(AK_SINTAGS_AVALABLE_HELPERS);
} else {
$AkHelperLoader = Ak::getStaticVar('AkHelperLoader');
$AkHelperLoader->instantiateHelpers();
if ($underscored_helper_names = AkHelperLoader::getInstantiatedHelperNames()) {
foreach ($underscored_helper_names as $underscored_helper_name) {
$helper_class_name = AkInflector::camelize($underscored_helper_name);
if (class_exists($helper_class_name)) {
$methods = get_class_methods($helper_class_name);
$vars = get_class_vars($helper_class_name);
if (AK_PHP5 && isset($vars['dynamic_helpers'])) {
$dynamic_helpers = Ak::toArray($vars['dynamic_helpers']);
foreach ($dynamic_helpers as $method_name) {
$this->dynamic_helpers[$method_name] = $underscored_helper_name;
}
}
foreach (get_class_methods($helper_class_name) as $method_name) {
if ($method_name[0] != '_') {
$helpers[$method_name] = $underscored_helper_name;
}
}
}
}
$helpers['render'] = 'controller';
$helpers['render_partial'] = 'controller';
}
}
$this->available_helpers = $helpers;
}
return $this->available_helpers;
}
示例12: AkCacheHandler
static function &getInstance(AkActionController &$Controller)
{
if (!($CacheHandler = Ak::getStaticVar('AkCacheHandlerSingleton'))) {
$settings = Ak::getSettings('caching', false);
if (!empty($settings['enabled'])) {
$CacheHandler = new AkCacheHandler();
$CacheHandler->init($Controller);
Ak::setStaticVar('AkCacheHandlerSingleton', $CacheHandler);
}
}
return $CacheHandler;
}
示例13: getInstance
static function getInstance()
{
if (!($Request = Ak::getStaticVar('AkRequestSingleton'))) {
$Request = new AkRequest();
Ak::setStaticVar('AkRequestSingleton', $Request);
}
return $Request;
}
示例14: getInstantiatedHelperNames
/**
* Returns an array of helper names like:
*
* array('url_helper', 'prototype_helper')
*/
function getInstantiatedHelperNames()
{
return Ak::getStaticVar('AkActionView::instantiated_helper_names');
}
示例15: getInstance
/**
* @return AkRouter
*/
static function getInstance()
{
if (!($Router = Ak::getStaticVar('AkRouterSingleton'))) {
$Router = new AkRouter();
$Router->loadMap();
Ak::setStaticVar('AkRouterSingleton', $Router);
}
return $Router;
}