/** * 工厂方法,产生日志数据聚合类。 * * @param string $identifier * @param boolean $throwException * @throws ZtChart_Model_Monitor_Aggregate_Exception * @return ZtChart_Model_Monitor_Aggregate_Abstract */ public static function factory($identifier, $throwException = true) { if (null === self::$_loader) { self::$_loader = new Zend_Loader_PluginLoader(array('ZtChart_Model_Monitor_Aggregate_' => realpath(__DIR__ . '/Aggregate'))); } $identifier = implode('_', array_map('ucfirst', explode('_', $identifier))); if (false === ($aggregateClass = self::$_loader->load($identifier, false))) { if (!$throwException) { return false; } throw new ZtChart_Model_Monitor_Aggregate_Exception("Specified aggregate class '{$identifier}' could not be found"); } return new $aggregateClass(); }
/** * 取得日志数据聚合分析的对象 * * @param string $identifier * @return false|ZtChart_Model_Monitor_Aggregate_Abstract */ public function getAggregate($identifier) { if (!array_key_exists($identifier, $this->_aggregates)) { try { $this->_aggregates[$identifier] = ZtChart_Model_Monitor_Aggregate::factory($identifier); } catch (ZtChart_Model_Monitor_Aggregate_Exception $e) { return false; } } return $this->_aggregates[$identifier]; }