Beispiel #1
0
 protected function mapAction($controller_class, $action)
 {
     try {
         Pfw_Loader::loadController($controller_class);
     } catch (Pfw_Exception_Loader $e) {
         throw new Pfw_Exception_NotFound("Could not find controller class '{$controller_class}'. " . "Please ensure class '{$controller_class}.php' exists within the 'controllers' directory", Pfw_Exception_NotFound::ROUTE_MISSING_ACTION);
     }
     $inst = new $controller_class();
     $methods_key = '_pfw_' . strtolower($controller_class) . '_methods';
     if (false === ($methods = Pfw_Cache_Local::get($methods_key))) {
         $methods = get_class_methods($inst);
         Pfw_Cache_Local::set($methods_key, $methods);
     }
     $methods = get_class_methods($inst);
     $n_action = $this->normalizeAct($action);
     foreach ($methods as $method) {
         if (!$this->isAlpha($method[0])) {
             continue;
         }
         if (self::ACTION_SUFFIX == substr($method, -6)) {
             $act_part = substr($method, 0, strlen($method) - 6);
             if ($n_action == $this->normalizeAct($act_part)) {
                 return array('controller' => $inst, 'controller_class' => $controller_class, 'method' => $method);
             }
         }
     }
     return array();
 }
Beispiel #2
0
$front = Pfw_Controller_Front::getInstance();
$front->getRouter()->setRoutes($_pfw_routes)->setModules($_pfw_modules);
$four_oh_four = false;
try {
    $front->dispatch();
} catch (Pfw_Exception_System $e) {
    $e->emitLog();
    if ($_ENVIRONMENT == "development") {
        objp($e);
        exit;
    }
    $four_oh_four = true;
} catch (Pfw_Exception_User $e) {
    $e->emitLog();
    if ($_ENVIRONMENT == "development") {
        objp($e);
        exit;
    }
    $four_oh_four = true;
} catch (Exception $e) {
    if ($_ENVIRONMENT == "development") {
        objp($e);
        exit;
    }
    $four_oh_four = true;
}
if ($four_oh_four) {
    Pfw_Loader::loadController('ErrorController');
    $c = new ErrorController();
    $c->fourohfourAction();
}