Пример #1
0
 /**
  * Routes the specified web request by setting the controller name, action and possible
  * parameters. If the request could not be routed, it will be left untouched.
  *
  * @param \F3\FLOW3\MVC\Web\Request $request The web request to be analyzed. Will be modified by the router.
  * @return void
  * @author Robert Lemke <*****@*****.**>
  * @author Bastian Waidelich <*****@*****.**>
  * @author Karsten Dambekalns <*****@*****.**>
  */
 public function route(\F3\FLOW3\MVC\Web\Request $request)
 {
     $this->request = $request;
     $requestPath = $this->request->getRequestPath();
     $matchResults = $this->findMatchResults($requestPath);
     if ($matchResults !== NULL) {
         $this->setControllerKeysAndFormat($matchResults);
         foreach ($matchResults as $argumentName => $argumentValue) {
             if ($argumentName[0] !== '@') {
                 $this->request->setArgument($argumentName, $argumentValue);
             }
         }
     }
     $this->setControllerKeysAndFormat($this->request->getArguments());
 }
 /**
  * Takes the raw request data and - depending on the request method
  * maps them into the request object. Afterwards all mapped arguments
  * can be retrieved by the getArgument(s) method, no matter if they
  * have been GET, POST or PUT arguments before.
  *
  * @param \F3\FLOW3\MVC\Web\Request $request The web request which will contain the arguments
  * @return void
  * @author Robert Lemke <*****@*****.**>
  */
 protected function setArgumentsFromRawRequestData(\F3\FLOW3\MVC\Web\Request $request)
 {
     foreach ($request->getRequestUri()->getArguments() as $argumentName => $argumentValue) {
         $request->setArgument($argumentName, $argumentValue);
     }
     switch ($request->getMethod()) {
         case 'POST':
             foreach ($this->environment->getRawPostArguments() as $argumentName => $argumentValue) {
                 $request->setArgument($argumentName, $argumentValue);
             }
             foreach ($this->environment->getUploadedFiles() as $argumentName => $argumentValue) {
                 if ($request->hasArgument($argumentName)) {
                     $existingArgumentValue = $request->getArgument($argumentName);
                     if (is_array($existingArgumentValue)) {
                         $request->setArgument($argumentName, \F3\FLOW3\Utility\Arrays::arrayMergeRecursiveOverrule($existingArgumentValue, $argumentValue));
                     }
                 } else {
                     $request->setArgument($argumentName, $argumentValue);
                 }
             }
             break;
             #			case 'PUT' :
             #				$putArguments = array();
             #				parse_str(file_get_contents("php://input"), $putArguments);
             #				foreach ($putArguments as $argumentName => $argumentValue) {
             #					$request->setArgument($argumentName, $argumentValue);
             #				}
             #			break;
     }
 }