Example #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;
 }