本文整理汇总了PHP中Ak::setStaticVar方法的典型用法代码示例。如果您正苦于以下问题:PHP Ak::setStaticVar方法的具体用法?PHP Ak::setStaticVar怎么用?PHP Ak::setStaticVar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ak
的用法示例。
在下文中一共展示了Ak::setStaticVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deliver
public function deliver(&$Mailer, $settings = array())
{
$encoded_message = $Mailer->getRawMessage();
$settings['ActionMailer']->deliveries[] = $encoded_message;
if (!AK_PRODUCTION_MODE) {
$Logger = Ak::getLogger('mail');
$Logger->message($encoded_message);
}
if (AK_TEST_MODE) {
Ak::setStaticVar('last_mail_delivered', $encoded_message);
}
}
示例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: addObserver
/**
* Register the reference to an object object
*
*
* @param $observer AkObserver
* @param $options array of options for the observer
* @return void
*/
public function addObserver($observer)
{
$staticVarNs = 'AkActiveModel::observers::' . $this->_Model->getModelName();
$observer_class_name = get_class($observer);
/**
* get the statically stored observers for the namespace
*/
$observers = Ak::getStaticVar($staticVarNs);
if (!is_array($observers)) {
$observers = array('classes' => array(), 'objects' => array());
}
/**
* if not already registered, the observerclass will
* be registered now
*/
if (!in_array($observer_class_name, $observers['classes'])) {
$observers['classes'][] = $observer_class_name;
$observers['objects'][] = $observer;
Ak::setStaticVar($staticVarNs, $observers);
}
}
示例5: 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']);
}
}
}
}
}
示例6: recognizeRouteForPath
public function recognizeRouteForPath($path, $request_method = null)
{
$path = is_string($path) ? '/' . ltrim($path, '/') : (function_exists($path) ? $path() : $path);
// Assume given controller
Ak::setStaticVar('AkRouterSingleton', $this->Router);
$Request = $this->_UnitTester->partialMock('AkRequest', array('getRequestedUrl', 'getPath', 'getMethod'), array('getRequestedUrl' => $path, 'getPath' => $path, 'getMethod' => empty($request_method) ? 'get' : $request_method));
Ak::setStaticVar('AkRequestSingleton', $Request);
$Request->mapRoutes($this->Router);
$UrlWriter = new AkUrlWriter($Request, $this->Router);
Ak::setStaticVar('AkUrlWriterSingleton', $UrlWriter);
return $Request;
}
示例7: 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);
}
示例8: profile
/**
* Add a profile message that can be displayed after executing the script
*
* You can add benchmark markers by calling
*
* Ak::profile('Searching for books');
*
* To display the results you need to call
*
* Ak::profile(true);
*
* You might also find handy adding this to your application controller.
*
* class ApplicationController extends BaseActionController
* {
* function __construct(){
* $this->afterFilter('_displayBenchmark');
* parent::__construct();
* }
* public function _displayBenchmark(){
* Ak::profile(true);
* }
* }
*
* IMPORTANT NOTE: You must define AK_ENABLE_PROFILER to true for this to work.
*/
function profile($message = '')
{
if(AK_ENABLE_PROFILER){
if(!$ProfileTimer = $Timer = Ak::getStaticVar('ProfileTimer')){
require_once 'Benchmark/Timer.php';
$ProfileTimer = new Benchmark_Timer();
$ProfileTimer->start();
Ak::setStaticVar('ProfileTimer', $ProfileTimer);
}elseif($message === true){
$ProfileTimer->display();
}else {
$ProfileTimer->setMarker($message);
}
}
}
示例9: tearDown
public function tearDown()
{
foreach (array_keys($this->_singletons) as $singleton) {
Ak::setStaticVar($singleton, $this->_singletons[$singleton]);
}
}
示例10: ak_test_case
function ak_test_case($test_case_name, $show_enviroment_flags = true)
{
$test_cases = (array) Ak::getStaticVar('ak_test_cases');
$test_cases[] = $test_case_name;
Ak::setStaticVar('ak_test_cases', $test_cases);
$levels = count(debug_backtrace());
if ($levels == 1 || $levels == 2 && isset($_ENV['SCRIPT_NAME']) && $_ENV['SCRIPT_NAME'] == 'dummy.php') {
if ($show_enviroment_flags) {
echo "(" . AK_ENVIRONMENT . " environment) Error reporting set to: " . AkConfig::getErrorReportingLevelDescription() . "\n";
}
ak_test($test_case_name);
}
}
示例11: availableTables
/**
* caching the meta info
*
* @return unknown
*/
function availableTables($force_lookup = false)
{
$available_tables = array();
!AK_TEST_MODE && $available_tables = Ak::getStaticVar('available_tables');
if(!$force_lookup && empty($available_tables)){
if (($available_tables = AkDbSchemaCache::get('avaliable_tables')) === false) {
if(empty($available_tables)){
$available_tables = $this->connection->MetaTables();
}
AkDbSchemaCache::set('avaliable_tables', $available_tables);
!AK_TEST_MODE && Ak::setStaticVar('available_tables', $available_tables);
}
}
$available_tables = $force_lookup ? $this->connection->MetaTables() : $available_tables;
$force_lookup && !AK_TEST_MODE && Ak::setStaticVar('available_tables', $available_tables);
return $available_tables;
}
示例12: getInstance
static function getInstance()
{
if (!($UrlWriter = Ak::getStaticVar('AkUrlWriterSingleton'))) {
$UrlWriter = new AkUrlWriter();
Ak::setStaticVar('AkUrlWriterSingleton', $UrlWriter);
}
return $UrlWriter;
}
示例13: 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;
}
示例14: instantiateHelpers
/**
* Creates an instance of each available helper and links it into into current controller.
*
* Per example, if a helper TextHelper is located into the file text_helper.php.
* An instance is created on current controller
* at $this->text_helper. This instance is also available on the view by calling $text_helper.
*
* Helpers can be found at lib/AkActionView/helpers (this might change in a future)
*/
function instantiateHelpers()
{
Ak::setStaticVar('AkHelperLoader', $this->getHelperLoader());
return;
require_once AK_LIB_DIR . DS . 'AkActionView' . DS . 'AkHelperLoader.php';
$HelperLoader = new AkHelperLoader();
$HelperLoader->setController(&$this);
$HelperLoader->instantiateHelpers();
Ak::setStaticVar('AkHelperLoader', $HelperLoader);
}
示例15: getInstance
static function getInstance()
{
if (!($Request = Ak::getStaticVar('AkRequestSingleton'))) {
$Request = new AkRequest();
Ak::setStaticVar('AkRequestSingleton', $Request);
}
return $Request;
}