コード例 #1
0
ファイル: Profiler.php プロジェクト: nstapelbroek/Glitch_Lib
 /**
  * Retrieves the request object
  *
  * @return Zend_Controller_Request_Abstract
  */
 public function getProfiler()
 {
     if (null === $this->_profiler) {
         $options = $this->getOptions();
         // Force these options to be set - don't rely on the defaults!
         if (!isset($options['active'])) {
             throw new Glitch_Exception('Undefined log option: "active"');
         }
         $enabled = (bool) $options['active'];
         // enable or disable the profiler by ratio
         if (isset($options['ratio'])) {
             $ratio = intval($options['ratio']);
             if ($ratio >= 0 && $ratio <= 100 && $enabled) {
                 $enabled = rand(0, 100) > 100 - $ratio;
             }
         }
         // load the profiler instance
         $this->_profiler = Glitch_Application_Profiler::factory($enabled);
         // Ensure the front controller is initialized
         $this->_bootstrap->bootstrap('FrontController');
         // push the profiler on the plugin stack to time the dispatch process
         $front = $this->_bootstrap->getResource('FrontController');
         $front->registerPlugin(new Glitch_Controller_Plugin_Profiler(), 2);
         // Allow application-wide access
         Zend_Registry::set(self::REGISTRY_KEY, $this->_profiler);
     }
     return $this->_profiler;
 }
コード例 #2
0
ファイル: Profiler.php プロジェクト: nstapelbroek/Glitch_Lib
 /**
  * getInstance
  *
  * @return	instance
  */
 public static function getInstance()
 {
     if (!self::$_instance) {
         self::$_instance = self::factory();
     }
     return self::$_instance;
 }