Example #1
0
 /**
  * Ext Direct does not provide named arguments by now, so we have
  * to map them by reflecting on the action parameters.
  *
  * @param RequestInterface $dispatchRequest
  * @param Transaction $transaction
  * @return array The mapped arguments
  */
 protected function getArgumentsFromTransaction(\F3\FLOW3\MVC\RequestInterface $dispatchRequest, \F3\ExtJS\ExtDirect\Transaction $transaction)
 {
     if (!$transaction->getDirectRequest()->isFormPost()) {
         $controllerClass = $dispatchRequest->getControllerObjectName();
         $parameters = $this->reflectionService->getMethodParameters($controllerClass, $dispatchRequest->getControllerActionName() . 'Action');
         return $transaction->mapDataToParameters($parameters);
     } else {
         // TODO Reuse setArgumentsFromRawRequestData from Web/RequestBuilder
     }
 }
 /**
  * Matches a \F3\FLOW3\MVC\RequestInterface against its set controller object name pattern rules
  *
  * @param \F3\FLOW3\MVC\RequestInterface $request The request that should be matched
  * @return boolean TRUE if the pattern matched, FALSE otherwise
  * @throws \F3\FLOW3\Security\Exception\RequestTypeNotSupportedException
  * @author Andreas Förthner <*****@*****.**>
  */
 public function matchRequest(\F3\FLOW3\MVC\RequestInterface $request)
 {
     return (bool) preg_match('/^' . str_replace('\\', '\\\\', $this->controllerObjectNamePattern) . '$/', $request->getControllerObjectName());
 }
 /**
  * Finds and instanciates a controller that matches the current request.
  * If no controller can be found, an instance of NotFoundControllerInterface is returned.
  *
  * @param \F3\FLOW3\MVC\RequestInterface $request The request to dispatch
  * @return \F3\FLOW3\MVC\Controller\ControllerInterface
  * @author Bastian Waidelich <*****@*****.**>
  */
 protected function resolveController(\F3\FLOW3\MVC\RequestInterface $request)
 {
     $exception = NULL;
     $packageKey = $request->getControllerPackageKey();
     if (!$this->packageManager->isPackageAvailable($packageKey)) {
         $exception = new \F3\FLOW3\MVC\Controller\Exception\InvalidPackageException($request, 'package "' . $packageKey . '" does not exist');
     } elseif (!$this->packageManager->isPackageActive($packageKey)) {
         $exception = new \F3\FLOW3\MVC\Controller\Exception\InactivePackageException($request, 'package "' . $packageKey . '" is not active');
     } else {
         $controllerObjectName = $request->getControllerObjectName();
         if ($controllerObjectName === '') {
             $exception = new \F3\FLOW3\MVC\Controller\Exception\InvalidControllerException($request, 'no controller could be resolved which would match your request');
         }
     }
     if ($exception !== NULL) {
         $controller = $this->objectManager->getObject($this->settings['mvc']['notFoundController']);
         if (!$controller instanceof \F3\FLOW3\MVC\Controller\NotFoundControllerInterface) {
             throw new \F3\FLOW3\MVC\Exception\InvalidControllerException('The NotFoundController must implement "\\F3\\FLOW3\\MVC\\Controller\\NotFoundControllerInterface", ' . (is_object($controller) ? get_class($controller) : gettype($controller)) . ' given.', 1246714416);
         }
         $controller->setException($exception);
     } else {
         $controller = $this->objectManager->getObject($controllerObjectName);
         if (!$controller instanceof \F3\FLOW3\MVC\Controller\ControllerInterface) {
             throw new \F3\FLOW3\MVC\Exception\InvalidControllerException('Invalid controller "' . $request->getControllerObjectName() . '". The controller must be a valid request handling controller, ' . (is_object($controller) ? get_class($controller) : gettype($controller)) . ' given.', 1202921619);
         }
     }
     return $controller;
 }