/** * Handle the exception. * Return the <code>ActionForward</code> instance (if any) returned by * the called <code>ExceptionHandler</code>. * * @param \Exception ex The exception to handle * @param \Phruts\Config\ExceptionConfig ae The ExceptionConfig corresponding to the exception * @param \Phruts\Action\ActionMapping mapping The ActionMapping we are processing * @param \Phruts\Action\AbstractActionForm formInstance The \Phruts\Action\AbstractActionForm we are processing * @param \Symfony\Component\HttpFoundation\Request request The actionKernel request we are processing * @param \Symfony\Component\HttpFoundation\Response response The actionKernel response we are creating * @return \Phruts\Config\ForwardConfig * @exception ActionKernelException if a actionKernel exception occurs * * @since Struts 1.1 */ public function execute(\Exception $ex, \Phruts\Config\ExceptionConfig $ae, \Phruts\Action\ActionMapping $mapping, \Phruts\Action\AbstractActionForm $formInstance = null, \Symfony\Component\HttpFoundation\Request $request, \Symfony\Component\HttpFoundation\Response $response) { $forward = null; //ActionForward $error = null; //\Phruts\Action\ActionError $property = null; //String // Build the forward from the exception mapping if it exists // or from the form input if ($ae->getPath() != null) { $forward = new \Phruts\Config\ForwardConfig(); $forward->setPath($ae->getPath()); } else { $forward = $mapping->getInputForward(); } // Figure out the error if ($ex instanceof \Phruts\Util\ModuleException) { $error = $ex->getActionMessage(); $property = $ex->getProperty(); } else { $error = new \Phruts\Action\ActionError($ae->getKey(), $ex->getMessage()); $property = $error->getKey(); } // Store the exception $request->attributes->set(\Phruts\Util\Globals::EXCEPTION_KEY, $ex); $this->storeException($request, $property, $error, $forward, $ae->getScope()); return $forward; }
public function setUp() { $this->moduleConfig = new \Phruts\Config\ModuleConfig('example'); $forwardConfig1 = new \Phruts\Config\ForwardConfig(); $forwardConfig1->setName('path1'); $this->moduleConfig->addForwardConfig($forwardConfig1); $this->actionMapping = new \Phruts\Action\ActionMapping(); $forwardConfig2 = new \Phruts\Config\ForwardConfig(); $forwardConfig2->setName('path2'); $this->actionMapping->addForwardConfig($forwardConfig2); $this->actionMapping->setModuleConfig($this->moduleConfig); }
/** * <p>Create (if necessary) and return an {@link ActionForward} that * corresponds to the <code>input</code> property of this Action.</p> * * @return \Phruts\Config\ForwardConfig The input forward for this action mapping. * @since Struts 1.1 */ public function getInputForward() { $controllerInputForward = null; $controllerConfig = $this->getModuleConfig()->getControllerConfig(); if (!empty($controllerConfig)) { $controllerInputForward = $controllerConfig->getInputForward(); } if ($controllerInputForward == true) { return $this->findForward($this->getInput()); } else { $forward = new \Phruts\Config\ForwardConfig(); $forward->setPath($this->getInput()); return $forward; } }
public function execute(ActionMapping $mapping, AbstractActionForm $form = null, Request $request, Response $response) { // Identify the request parameters controlling our actions $page = $request->get("page"); $prefix = $request->get("prefix"); if ($page == null || $prefix == null) { $message = $this->getActionKernel()->getInternal()->getMessage("switch.required", $mapping->getPath()); throw new \Phruts\Exception($message); } // Switch to the requested module \Phruts\Util\RequestUtils::selectModule($request, $this->getActionKernel()->getApplication()); if ($request->attributes->get(\Phruts\Util\Globals::MODULE_KEY) == null) { $message = $this->getActionKernel()->getInternal()->getMessage("switch.prefix", $prefix); $response->setContent(400); $response->setContent($message); return null; } // Forward control to the specified module-relative URI $forward = new \Phruts\Config\ForwardConfig(); $forward->setPath($page); return $forward; }