Example #1
0
 /**
  * Forwards the request to another action and / or controller.
  *
  * Request is directly transfered to the other action / controller
  *
  * @param string $actionName Name of the action to forward to
  * @param string $controllerName Unqualified object name of the controller to forward to. If not specified, the current controller is used.
  * @param string $packageKey Key of the package containing the controller to forward to. May also contain the sub package, concatenated with backslash (Vendor.Foo\Bar\Baz). If not specified, the current package is assumed.
  * @param array $arguments Arguments to pass to the target action
  * @return void
  * @throws \TYPO3\FLOW3\Mvc\Exception\ForwardException
  * @see redirect()
  * @api
  */
 protected function forward($actionName, $controllerName = NULL, $packageKey = NULL, array $arguments = array())
 {
     $nextRequest = clone $this->request;
     $nextRequest->setControllerActionName($actionName);
     if ($controllerName !== NULL) {
         $nextRequest->setControllerName($controllerName);
     }
     if ($packageKey !== NULL && strpos($packageKey, '\\') !== FALSE) {
         list($packageKey, $subpackageKey) = explode('\\', $packageKey, 2);
     } else {
         $subpackageKey = NULL;
     }
     if ($packageKey !== NULL) {
         $nextRequest->setControllerPackageKey($packageKey);
     }
     if ($subpackageKey !== NULL) {
         $nextRequest->setControllerSubpackageKey($subpackageKey);
     }
     $regularArguments = array();
     foreach ($arguments as $argumentName => $argumentValue) {
         if (substr($argumentName, 0, 2) === '__') {
             $nextRequest->setArgument($argumentName, $argumentValue);
         } else {
             $regularArguments[$argumentName] = $argumentValue;
         }
     }
     $nextRequest->setArguments($this->persistenceManager->convertObjectsToIdentityArrays($regularArguments));
     $this->arguments->removeAll();
     $forwardException = new \TYPO3\FLOW3\Mvc\Exception\ForwardException();
     $forwardException->setNextRequest($nextRequest);
     throw $forwardException;
 }
Example #2
0
 /**
  * Forwards the request to another command and / or CommandController.
  *
  * Request is directly transferred to the other command / controller
  * without the need for a new request.
  *
  * @param string $commandName
  * @param string $controllerObjectName
  * @param array $arguments
  * @return void
  * @throws \TYPO3\FLOW3\Mvc\Exception\StopActionException
  */
 protected function forward($commandName, $controllerObjectName = NULL, array $arguments = array())
 {
     $this->request->setDispatched(FALSE);
     $this->request->setControllerCommandName($commandName);
     if ($controllerObjectName !== NULL) {
         $this->request->setControllerObjectName($controllerObjectName);
     }
     $this->request->setArguments($arguments);
     $this->arguments->removeAll();
     throw new \TYPO3\FLOW3\Mvc\Exception\StopActionException();
 }
Example #3
0
 /**
  * @test
  * @expectedException TYPO3\FLOW3\Mvc\Exception\RequiredArgumentMissingException
  */
 public function mapRequestArgumentsToControllerArgumentsThrowsExceptionIfRequiredArgumentWasNotSet()
 {
     $httpRequest = HttpRequest::create(new Uri('http://localhost/'));
     $request = $httpRequest->createActionRequest();
     $response = new HttpResponse();
     $controllerArguments = new Arguments();
     $controllerArguments->addNewArgument('foo', 'string', TRUE);
     $controller = $this->getAccessibleMock('TYPO3\\FLOW3\\Mvc\\Controller\\AbstractController', array('processRequest'));
     $this->inject($controller, 'flashMessageContainer', new FlashMessageContainer());
     $controller->_call('initializeController', $request, $response);
     $controller->_set('arguments', $controllerArguments);
     $controller->_call('mapRequestArgumentsToControllerArguments');
 }
 /**
  * Initialize the property mapping configuration in $controllerArguments if
  * the trusted properties are set inside the request.
  *
  * @param \TYPO3\FLOW3\Mvc\ActionRequest $request
  * @param \TYPO3\FLOW3\Mvc\Controller\Arguments $controllerArguments
  * @return void
  */
 public function initializePropertyMappingConfigurationFromRequest(\TYPO3\FLOW3\Mvc\ActionRequest $request, \TYPO3\FLOW3\Mvc\Controller\Arguments $controllerArguments)
 {
     $trustedPropertiesToken = $request->getInternalArgument('__trustedProperties');
     if (!is_string($trustedPropertiesToken)) {
         return;
     }
     $serializedTrustedProperties = $this->hashService->validateAndStripHmac($trustedPropertiesToken);
     $trustedProperties = unserialize($serializedTrustedProperties);
     foreach ($trustedProperties as $propertyName => $propertyConfiguration) {
         if (!$controllerArguments->hasArgument($propertyName)) {
             continue;
         }
         $propertyMappingConfiguration = $controllerArguments->getArgument($propertyName)->getPropertyMappingConfiguration();
         $this->modifyPropertyMappingConfiguration($propertyConfiguration, $propertyMappingConfiguration);
     }
 }
Example #5
0
 /**
  * @test
  */
 public function addingAnArgumentUsesStringAsDataTypeDefault()
 {
     $arguments = new Arguments();
     $argument = $arguments->addNewArgument('someArgumentName');
     $this->assertEquals('string', $argument->getDataType());
 }
Example #6
0
 /**
  * @test
  */
 public function getValidationResultsShouldFetchAllValidationResltsFromArguments()
 {
     $error1 = new \TYPO3\FLOW3\Error\Error('Validation error', 1234);
     $error2 = new \TYPO3\FLOW3\Error\Error('Validation error 2', 1235);
     $results1 = new \TYPO3\FLOW3\Error\Result();
     $results1->addError($error1);
     $results2 = new \TYPO3\FLOW3\Error\Result();
     $results2->addError($error2);
     $argument1 = $this->getMock('TYPO3\\FLOW3\\Mvc\\Controller\\Argument', array('getValidationResults'), array('name1', 'string'));
     $argument1->expects($this->once())->method('getValidationResults')->will($this->returnValue($results1));
     $argument2 = $this->getMock('TYPO3\\FLOW3\\Mvc\\Controller\\Argument', array('getValidationResults'), array('name2', 'string'));
     $argument2->expects($this->once())->method('getValidationResults')->will($this->returnValue($results2));
     $arguments = new \TYPO3\FLOW3\Mvc\Controller\Arguments();
     $arguments->addArgument($argument1);
     $arguments->addArgument($argument2);
     $this->assertSame(array('name1' => array($error1), 'name2' => array($error2)), $arguments->getValidationResults()->getFlattenedErrors());
 }