Exemplo n.º 1
0
 /**
  * 设置路由方式
  * @param string $routeType
  * @return \tfc\mvc\UrlManager
  * @throws InvalidArgumentException 如果参数不是有效的路由方式,抛出异常
  */
 public function setRouteType($routeType = null)
 {
     if ($routeType === null) {
         $route = Mvc::getRouter()->getCurrRoute();
         if ($this->isSupervar($route)) {
             $routeType = self::ROUTE_SUPERVAR;
         } elseif ($this->isRewrite($route)) {
             $routeType = self::ROUTE_REWRITE;
         } elseif ($this->isSimple($route)) {
             $routeType = self::ROUTE_SIMPLE;
         }
     }
     $routeType = strtoupper((string) $routeType);
     if (!defined('static::ROUTE_' . $routeType)) {
         throw new InvalidArgumentException(sprintf('UrlManager Route Type "%s" invalid.', $routeType));
     }
     $this->_routeType = $routeType;
     return $this;
 }
Exemplo n.º 2
0
 /**
  * 初始化默认的module、controller和action名
  * @return void
  */
 public function _initDefaultRouter()
 {
     $router = Mvc::getRouter();
     $router->setDefaultModule('posts')->setDefaultController('show')->setDefaultAction('home');
 }
Exemplo n.º 3
0
 /**
  * 初始化默认的module、controller和action名
  * @return void
  */
 public function _initDefaultRouter()
 {
     $router = Mvc::getRouter();
     $router->setDefaultModule('system')->setDefaultController('site')->setDefaultAction('index');
 }