Exemplo n.º 1
0
function init($controller, $method)
{
    // include controller file
    require_once 'controllers/' . $controller . '.php';
    // create controller objects
    switch ($controller) {
        // special cases
        case 'pages':
            $controller = new PagesController();
            $controller->showPage($method);
            break;
        case 'error':
            $controller = new ErrorController();
            $controller->showError($method);
            break;
            // standard controllers
        // standard controllers
        case 'sorting':
            $controller = new SortingController();
    }
    // 'pages' and 'error' controllers do not use this
    if (method_exists($controller, $method)) {
        // call requested method from controller
        $controller->{$method}();
    }
}