Exemplo n.º 1
0
 /**
  * 
  * @static
  * @return ZtChart_Model_Monitor_Console
  */
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Exemplo n.º 2
0
 /**
  * 构造函数
  * 
  * @param string $daemon
  * @param array|Zend_Config $config
  * @param ZtChart_Model_Monitor_Console $console
  */
 public function __construct($daemon, $config = array(), ZtChart_Model_Monitor_Console $console = null)
 {
     if ($config instanceof Zend_Config) {
         $config = $config->toArray();
     }
     if (null === $console) {
         $console = ZtChart_Model_Monitor_Console::getInstance();
     }
     $loader = new Zend_Loader_PluginLoader(array('ZtChart_Model_Monitor_Daemon' => realpath(__DIR__ . '/Monitor/Daemon')));
     if (false === ($daemonClass = $loader->load($daemon, false))) {
         throw new ZtChart_Model_Monitor_Exception("Specified daemon class '{$daemon}' could not be found.");
     } else {
         if (!is_subclass_of($daemonClass, 'ZtChart_Model_Monitor_Daemon_Abstract')) {
             throw new ZtChart_Model_Monitor_Exception("Specified daemon class '{$daemon}' is illegal.");
         } else {
             $this->_daemon = new $daemonClass($console, $config);
         }
     }
 }