/** * 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 testGetInputForward() { // Input forward $this->actionMapping->setInput('aPath'); $forward = $this->actionMapping->getInputForward(); $this->assertNotEmpty($forward); $this->assertEquals('aPath', $forward->getPath()); // Controller based input forward $controllerConfig = new \Phruts\Config\ControllerConfig(); $controllerConfig->setInputForward(true); $this->actionMapping->setInput('path1'); $this->moduleConfig->setControllerConfig($controllerConfig); $forward = $this->actionMapping->getInputForward(); $this->assertNotEmpty($forward); $this->assertEquals('path1', $forward->getName()); }