/** * Singleton instance * * @return Cola_Router */ public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
/** * Get dispatch info * * @param boolean $init * @return array */ public function getDispatchInfo($init = false) { if (null === $this->dispatchInfo && $init) { $this->router || ($this->router = new Cola_Router()); if ($urls = self::getConfig('_urls')) { $this->router->rules += $urls; } $this->pathInfo || ($this->pathInfo = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : ''); $this->dispatchInfo = $this->router->match($this->pathInfo); } return $this->dispatchInfo; }
/** * Set router * * @param Cola_Router $router * @return Cola */ public function setRouter($router = null) { if (null === $router) { $router = Cola_Router::getInstance(); } $this->_router = $router; return $this; }