/** * Adds a TLogRoute instance to the log router. * * @param TLogRoute $route * @throws TInvalidDataTypeException if the route object is invalid */ public function addRoute($route) { if (!$route instanceof TLogRoute) { throw new TInvalidDataTypeException('logrouter_routetype_invalid'); } $this->_routes[] = $route; $route->init(null); }
/** * Initializes this module. * This method is required by the IModule interface. * It initializes the database for logging purpose. * @param TXmlElement configuration for this module, can be null * @throws TConfigurationException if the DB table does not exist. */ public function init($config) { $db = $this->getDbConnection(); $db->setActive(true); $sql = 'SELECT * FROM ' . $this->_logTable . ' WHERE 0=1'; try { $db->createCommand($sql)->query()->close(); } catch (Exception $e) { // DB table not exists if ($this->_autoCreate) { $this->createDbTable(); } else { throw new TConfigurationException('db_logtable_inexistent', $this->_logTable); } } parent::init($config); }