Example #1
0
/**
 * 
 * Front Controller
 */
function dispatch($route)
{
    if (empty($route)) {
        exit('acce');
    }
    //erro page 404 выводить если нет такой страницы
    $controllerClass = 'Controller_' . $route['controller'];
    //формируем имя контролер
    $controllerFile = APP_PATH . DS . 'classes' . DS . str_replace('.', ' ', className2fileName($controllerClass)) . '.php';
    /*
    $refl = new ReflectionMethod($controllerClass,$route['action']);
    
    $reqParamsNo= $refl->getNumberOfRequiredParameters();
    if (count($route['params'])<$reqParamsNo)
        {
        exit('Wroms params umbors');
        }*/
    $refl = new ReflectionClass($controllerClass);
    if ($refl->hasMethod($route['action'])) {
        $controller = $refl->newInstance();
        $action = $refl->getMethod($route['action']);
        if ($action->getNumberOfRequiredParameters() > count($route['params'])) {
            exit('Wrong page');
        } else {
            $action->invokeArgs($controller, $route['params']);
        }
    } else {
        exit('Wrong page');
    }
}
Example #2
0
 public function __construct($layout = '', $view = '')
 {
     $this->_conf = Config::instance();
     if (!empty($layout)) {
         $this->_layout = $layout;
     } else {
         $this->_layout = $this->_conf->get('default_layout');
     }
     if (!empty($view)) {
         $this->_view = $view;
     } else {
         $router = Route::instance();
         $this->_view = className2fileName($router->controller()) . DS . $router->action();
     }
 }
Example #3
0
/**
 * 
 * автолод для подключения классов
 */
function __autoload($class)
{
    $file = className2fileName($class) . '.php';
    include_once $file;
}