예제 #1
0
 public function execute(ActionMapping $mapping, AbstractActionForm $form = null, Request $request, Response $response)
 {
     // Action Config defines the parameter for the forward configuration
     $parameter = $mapping->getParameter();
     if (empty($parameter)) {
         throw new \Phruts\Exception\IllegalArgumentException('Need to specify a parameter for this ForwardAction');
     }
     // Original strategy, let's assume it is a path
     if (!preg_match('/^[A-z]+$/', $parameter)) {
         $forward = new ForwardConfig();
         $forward->setPath($parameter);
         $forward->setContextRelative(true);
         return $forward;
     } else {
         // Forward the request
         $forward = $mapping->findForwardConfig($parameter);
         if (empty($forward)) {
             throw new \Phruts\Exception('ForwardAction parameter should reference a forward config name');
         }
         return $forward;
     }
 }
예제 #2
0
 /**
  * Method which is dispatched to when there is no value for specified
  * request parameter included in the request.  Subclasses of
  * <code>DispatchAction</code> should override this method if they wish
  * to provide default behavior different than producing an HTTP
  * "Bad Request" error.
  *
  */
 protected function unspecified(ActionMapping $mapping, AbstractActionForm $form = null, Request $request, Response $response)
 {
     $message = $this->getActionKernel()->getInternal()->getMessage("dispatch.parameter", $mapping->getPath(), $mapping->getParameter());
     $response->setStatusCode(400);
     $response->setContent($message);
     return null;
 }