private function getName(Request $request)
 {
     $name = $request->getName();
     $method = $request->getMethod();
     if ($name === 'order' && $method === Request::POST) {
         return 'OrderCreate';
     } elseif ($name === 'order' && $method === Request::GET) {
         return 'OrderStatus';
     } elseif ($name === 'product' && $method === Request::GET) {
         return 'ItemStatus';
     }
     throw new InvalidRequestException("Invalid request: {$method} {$name}");
 }
Example #2
0
 private function handle($command)
 {
     $request = new Request($command);
     $response = new Response();
     $name = $request->getName();
     if (!empty($name)) {
         if ($this->hasCommand($name)) {
             $command = $this->getCommand($name);
             $handler = $command->getHandler();
             call_user_func_array($handler, [$request, $response]);
         } else {
             $command = $request->getCommand();
             passthru($command);
             $response->line();
             //echo "command '{$name}' not found\n";
         }
     }
 }
Example #3
0
 /**
  * Summary of requestReservationSent
  * @param Request $request
  * @param User $target
  */
 public static function requestReservationSent(Request $request, User $target)
 {
     self::send("Reservation of request {$request->getId()} ({$request->getName()}) sent to {$target->getUsername()} by " . User::getCurrent()->getUsername());
 }