Exemple #1
1
 function getCommand(Request $req)
 {
     $previous = $req->getLastCommand();
     if (!$previous) {
         $cmd = $req->getProperty('cmd');
         if (!$cmd) {
             $req->setProperty('cmd', 'default');
             return self::$default_cmd;
         }
     } else {
         $cmd = $this->getForward($req);
         if (!$cmd) {
             return null;
         }
     }
     $cmd_obj = $this->resolveCommand($cmd);
     if (!$cmd_obj) {
         throw new \woo\base\AppException("couldn't resolve '{$cmd}'");
     }
     $cmd_class = get_class($cmd_obj);
     if (isset($this->invoked[$cmd_class])) {
         throw new \woo\base\AppException("circular forwarding");
     }
     $this->invoked[$cmd_class] = 1;
     return $cmd_obj;
 }
 /**
  * Exception handler.
  */
 public function handleException(\Exception $ex)
 {
     $request = new Request();
     $request->addFeedback($ex);
     if ($ex instanceof \Classes\Controller\Exception\NotFoundException) {
         $request->setProperty('cmd', '404');
     } else {
         $request->setProperty('cmd', '500');
     }
     $cmd_r = new \Classes\Controller\Command\CommandResolver();
     $cmd = $cmd_r->getCommand($request);
     $cmd->execute($request);
 }