Esempio n. 1
0
 /**
  * 添加路由器重写规则
  * @param string $name 名称
  * @param XF_Controller_Router_Rewrite_Interface $rewrite
  * @param int $index 执行优先级,数值越大将最先被执行
  * @return XF_Controller_Router_Abstract
  */
 public function addRewrite($name, XF_Controller_Router_Rewrite_Abstract $rewrite, $index = NULL)
 {
     $name = (string) $name;
     if ($index === NULL) {
         if (count($this->_rewrite_index) === 0) {
             $this->_rewrite_index[0] = $name;
         } else {
             $array = array_keys($this->_rewrite_index);
             $index = end($array);
             $this->_rewrite_index[$index + 1] = $name;
         }
     } else {
         XF_Functions::arrayInsert($this->_rewrite_index, $index, $name);
     }
     $this->_rewrites[$name] = $rewrite;
     if ($rewrite->isDisableDefaultRoute()) {
         $m = $rewrite->getMca();
         $this->disabledDefaultRouter($m['module'], $m['controller'], $m['action']);
     }
     return $this;
 }