예제 #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
 public function testForwardConfig()
 {
     $config = new ForwardConfig();
     $config->setName('myName');
     $config->setPath('path.php');
     $config->setContextRelative('no');
     $config->setNextActionPath('myNextPath');
     $config->setRedirect('false');
     // TODO: Update the expected to include redirect, next action and context relative
     $expected = "\\Phruts\\Config\\ForwardConfig[name='myName',path='path.php',redirect=false]";
     $this->assertEquals($expected, (string) $config);
     // TODO: Test exception
     $config->freeze();
     $this->setExpectedException('\\Phruts\\Exception\\IllegalStateException');
     $config->setName('name');
 }