当前位置: 首页>>代码示例>>PHP>>正文


PHP Kwf_Registry::getInstance方法代码示例

本文整理汇总了PHP中Kwf_Registry::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Kwf_Registry::getInstance方法的具体用法?PHP Kwf_Registry::getInstance怎么用?PHP Kwf_Registry::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Kwf_Registry的用法示例。


在下文中一共展示了Kwf_Registry::getInstance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: preProcessInput

 public function preProcessInput()
 {
     //use custom user model
     Kwf_Registry::get('config')->user->model = 'Kwc_FavouritesSelenium_UserModel';
     //unset existing userModel instance to get new one
     $reg = Kwf_Registry::getInstance()->set('userModel', Kwf_Model_Abstract::getInstance('Kwc_FavouritesSelenium_UserModel'));
 }
开发者ID:koala-framework,项目名称:koala-framework,代码行数:7,代码来源:Component.php

示例2: tearDown

 public function tearDown()
 {
     parent::tearDown();
     Kwf_Registry::getInstance()->offsetUnset('config');
     //re-reads config, undoes changes to config done above
     Kwf_Registry::getInstance()->offsetUnset('userModel');
     Kwf_Registry::get('config')->user->model = $this->presetModel;
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:8,代码来源:SeleniumTest.php

示例3: runAction

 public function runAction()
 {
     $debug = $this->_getParam('debug');
     if (file_exists('temp/shutdown-maintenance')) {
         unlink('temp/shutdown-maintenance');
     }
     $lastDailyRun = null;
     if (file_exists('temp/maintenance-daily-run')) {
         $lastDailyRun = file_get_contents('temp/maintenance-daily-run');
         if ($debug) {
             echo "last daily run: " . date('Y-m-d H:i:s', $lastDailyRun) . "\n";
         }
     }
     $lastHourlyRun = null;
     if (file_exists('temp/maintenance-hourly-run')) {
         $lastHourlyRun = file_get_contents('temp/maintenance-hourly-run');
         if ($debug) {
             echo "last hourly run: " . date('Y-m-d H:i:s', $lastHourlyRun) . "\n";
         }
     }
     $dailyMaintenanceWindowStart = "01:00";
     //don't set before 00:00
     $dailyMaintenanceWindowEnd = "05:00";
     $nextDailyRun = null;
     $lastMinutelyRun = null;
     while (true) {
         if (!$nextDailyRun) {
             if ($lastDailyRun && $lastDailyRun > strtotime($dailyMaintenanceWindowStart)) {
                 //today already run
                 //maintenance window of tomorrow
                 $nextDailyRun = rand(strtotime("tomorrow {$dailyMaintenanceWindowStart}"), strtotime("tomorrow {$dailyMaintenanceWindowEnd}"));
             } else {
                 //not yet run or today not yet run
                 if (time() < strtotime($dailyMaintenanceWindowEnd)) {
                     //window not yet over for today
                     //maintenance window of today
                     $nextDailyRun = rand(max(time(), strtotime($dailyMaintenanceWindowStart)), strtotime($dailyMaintenanceWindowEnd));
                 } else {
                     //maintenance window of tomorrow
                     $nextDailyRun = rand(strtotime("tomorrow {$dailyMaintenanceWindowStart}"), strtotime("tomorrow {$dailyMaintenanceWindowEnd}"));
                 }
             }
             if ($debug) {
                 echo "Next daily run: " . date('Y-m-d H:i:s', $nextDailyRun) . "\n";
             }
         }
         Kwf_Util_Maintenance_Dispatcher::executeJobs(Kwf_Util_Maintenance_Job_Abstract::FREQUENCY_SECONDS, $debug);
         if (!$lastMinutelyRun || time() - $lastMinutelyRun > 60) {
             $lastMinutelyRun = time();
             Kwf_Util_Maintenance_Dispatcher::executeJobs(Kwf_Util_Maintenance_Job_Abstract::FREQUENCY_MINUTELY, $debug);
             //discard connection to database to reconnect on next job run
             //avoids problems with auto closed connections due to inactivity
             if (function_exists('gc_collect_cycles()')) {
                 Kwf_Model_Abstract::clearAllRows();
                 Kwf_Model_Abstract::clearInstances();
                 gc_collect_cycles();
                 Kwf_Registry::getInstance()->offsetUnset('db');
                 Kwf_Registry::getInstance()->offsetUnset('dao');
             }
         }
         Kwf_Component_Data_Root::getInstance()->freeMemory();
         if (!$lastHourlyRun || time() - $lastHourlyRun > 3600) {
             if ($debug) {
                 echo date('Y-m-d H:i:s') . " execute hourly jobs\n";
             }
             $lastHourlyRun = time();
             file_put_contents('temp/maintenance-hourly-run', $lastHourlyRun);
             Kwf_Util_Maintenance_Dispatcher::executeJobs(Kwf_Util_Maintenance_Job_Abstract::FREQUENCY_HOURLY, $debug);
         }
         Kwf_Component_Data_Root::getInstance()->freeMemory();
         if (time() > $nextDailyRun) {
             if ($debug) {
                 echo date('Y-m-d H:i:s') . " execute daily jobs\n";
             }
             $lastDailyRun = time();
             file_put_contents('temp/maintenance-daily-run', $lastDailyRun);
             $nextDailyRun = null;
             Kwf_Util_Maintenance_Dispatcher::executeJobs(Kwf_Util_Maintenance_Job_Abstract::FREQUENCY_DAILY, $debug);
         }
         sleep(10);
     }
 }
开发者ID:koala-framework,项目名称:koala-framework,代码行数:82,代码来源:MaintenanceJobsController.php

示例4: tearDown

 public function tearDown()
 {
     parent::tearDown();
     Kwf_Registry::get('config')->user->model = $this->_previousUserModel;
     Kwf_Registry::getInstance()->offsetUnset('userModel');
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:6,代码来源:BoxTest.php


注:本文中的Kwf_Registry::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。