Example #1
0
 protected function findController($requestPath, $subDir = '')
 {
     list($controller, $method) = explode('/', $requestPath, 2);
     $controller = ucfirst($controller);
     if (is_dir(LIBRARY_PATH . "Controller/{$subDir}{$controller}")) {
         if (!$method) {
             $method = 'Index';
         }
         $this->findController($method, $subDir . $controller . '/');
     } elseif (file_exists(LIBRARY_PATH . "Controller/{$subDir}{$controller}.php")) {
         if (!$method) {
             $method = 'index';
         } else {
             $method = lcfirst($method);
         }
         $className = str_replace('/', '\\', "Controller/{$subDir}{$controller}");
         $controller = new $className();
         if (method_exists($controller, $method)) {
             Filter::afterRoute($className, $method);
             $context = $controller->{$method}();
             if ($context) {
                 Template::setContext($context);
             }
             Filter::preRender();
             Template::render();
             Filter::afterRender();
             $this->foundController = true;
         }
     }
 }