/** * Tests WindForward->forwardAction() * @dataProvider dataForForwardAction */ public function testForwardAction($action, $args, $isRedirect, $immediately) { if ($immediately) { try { $this->WindForward->forwardAction($action, $args, $isRedirect, $immediately); } catch (WindForwardException $e) { $this->assertEquals(array($action, $args, $isRedirect, true), array($e->getForward()->getAction(), $e->getForward()->getArgs(), $e->getForward()->getIsRedirect(), $e->getForward()->getIsReAction())); return; } $this->fail("ForwardAction Test Error!"); } else { $this->WindForward->forwardAction($action, $args, $isRedirect, $immediately); $this->assertEquals(array($action, $args, $isRedirect, true), array($this->WindForward->getAction(), $this->WindForward->getArgs(), $this->WindForward->getIsRedirect(), $this->WindForward->getIsReAction())); } }
/** * 重定向请求到新的action操作 * * 该种重定向类型,是中断当前的请求执行过程,开启另外的action操作处理.是在一次请求内部进行重定向, * 所以之前的一些处理的结果变量,在重定向后是会继续存在,并可通过forward变量进行访问的.也就是不仅仅是过程的重定向, * 也是状态的重定向. * @param WindForward $forward * @param WindRouter $router * @param boolean $display * @return void */ protected function dispatchWithAction($forward, $router, $display) { if (!($action = $forward->getAction())) { throw new WindException('[web.WindDispatcher.dispatchWithAction] forward fail.', WindException::ERROR_PARAMETER_TYPE_ERROR); } $this->display = $display; list($_a, $_c, $_m) = WindUrlHelper::resolveAction($action); if ($_var = $forward->getArgs()) { $this->getResponse()->setData($_var, 'F'); } $_a && $router->setAction($_a); $_c && $router->setController($_c); $_m && $router->setModule($_m); Wind::getApp()->run(); }
/** * 重定向请求到新的action操作 * * 该种重定向类型,是中断当前的请求执行过程,开启另外的action操作处理.是在一次请求内部进行重定向, * 所以之前的一些处理的结果变量,在重定向后是会继续存在,并可通过forward变量进行访问的.也就是不仅仅是过程的重定向, * 也是状态的重定向. * @param WindForward $forward * @param WindRouter $router * @param boolean $display * @return void */ protected function dispatchWithAction($forward, $router, $display) { if (!($action = $forward->getAction())) { throw new WindException('[web.WindDispatcher.dispatchWithAction] forward fail.', WindException::ERROR_PARAMETER_TYPE_ERROR); } $this->display = $display; list($_a, $_c, $_m, $arg) = WindUrlHelper::resolveAction($action); foreach ($arg as $key => $value) { $_GET[$key] = $value; } foreach ($forward->getArgs() as $key => $value) { $_POST[$key] = $value; } $_a && $router->setAction($_a); $_c && $router->setController($_c); $_m && $router->setModule($_m); Wind::getApp()->run(); }
public function postHandle() { $this->forward->setAction('post_' . $this->forward->getAction()); $this->errorMessage->addError('post_' . $this->errorMessage->getError(0), 0); }