예제 #1
0
파일: Route.php 프로젝트: Applaction/myMvc
 public function parseUrl()
 {
     $urlInfo = ParseUrl();
     $controller = $urlInfo['appName'] . '\\Controller\\' . $urlInfo['className'] . 'Controller';
     $obj = new $controller();
     if (!method_exists($obj, $urlInfo['methodName'])) {
         die('该方法不存在:' . $urlInfo['methodName']);
     }
     $methodName = $urlInfo['methodName'];
     $obj->{$methodName}();
 }
예제 #2
0
 public function __construct()
 {
     $this->smarty = oSmarty();
     $urlInfo = ParseUrl();
     $this->appName = $urlInfo['appName'];
     $this->className = $urlInfo['className'];
     $this->methodName = $urlInfo['methodName'];
     $this->templateDir = dirname(__FILE__) . "/../Runing/Template/" . $urlInfo['appName'] . '/' . $urlInfo['className'];
     $this->smarty->setTemplateDir($this->templateDir);
     $this->smarty->setCompileDir(dirname(__FILE__) . "/../Runing/Compile/" . $urlInfo['appName'] . '/' . $urlInfo['className']);
     $this->smarty->left_delimiter = getConfig('LEFT_LIMIT') ? getConfig('LEFT_LIMIT') : "{{";
     $this->smarty->right_delimiter = getConfig('RIGHT_LIMIT') ? getConfig('RIGHT_LIMIT') : "}}";
     //开启缓存
     if (getConfig('TPL_CACHE')) {
         $this->smarty->caching = true;
         $this->smarty->setCacheDir(dirname(__FILE__) . "/../Runing/Cache/" . $urlInfo['appName'] . '/' . $urlInfo['className']);
         $this->smarty->cache_lifetime = getConfig('CACHE_LIFETIME') ? getConfig('CACHE_LIFETIME') : 60;
     }
 }
예제 #3
0
/**
 * 获取当前的方法
 * @return mixed
 */
function CurrentMethod()
{
    $data = ParseUrl();
    return $data['methodName'];
}