Ejemplo n.º 1
0
 /**
  * Prepares the controller
  * @param Controller $controller The controller to prepare
  * @param Request $request The request for the controller
  * @param Response $response The response for the controller
  * @param string $actionName The method which will be invoked
  * @param array $parameters The parameters for that method
  * @return null
  */
 protected function prepareController(Controller $controller, Request $request, Response $response, $actionName, array $parameters)
 {
     if (!$this->passRequestParameters) {
         $request = new Request($request->getBaseUrl(), $request->getBasePath(), $request->getControllerName(), Dispatcher::ACTION_INDEX);
     }
     $this->widget->setRequest($request);
     $this->widget->setResponse($response);
 }
Ejemplo n.º 2
0
 /**
  * Gets a new request for chaining based on the provided arguments
  * @param string $controllerClass Full class name of the controller for the new request
  * @param string|null $action Action method in the controller
  * @param boolean|int|array $parameters provide an array as parameters for
  * the new request. If a boolean is provided, the parameters will be taken
  * from the request. Set the boolean to true and the first parameter will
  * be taken of the parameter array and added to the base path. You can also
  * provide the number of parameters to be taken of the parameter array and
  * added to the base path.
  * @param string $basePath the basePath for your new request. if none
  * specified, the base path will be taken from the current request
  * @return zibo\core\Request
  */
 protected function forward($controllerClass, $action = null, $parameters = true, $basePath = null)
 {
     $baseUrl = $this->request->getBaseUrl();
     if (!$basePath) {
         $basePath = $this->request->getBasePath();
     }
     if (!is_array($parameters)) {
         $requestParameters = $this->request->getParameters();
         if (is_bool($parameters) && $parameters) {
             $parameters = 1;
         }
         if (is_numeric($parameters) && $parameters > 0) {
             for ($i = 0; $i < $parameters; $i++) {
                 $basePathSuffix = array_shift($requestParameters);
                 $basePath .= Request::QUERY_SEPARATOR . $basePathSuffix;
             }
         }
         $parameters = $requestParameters;
     }
     return new Request($baseUrl, $basePath, $controllerClass, $action, $parameters, $this->request->getQueryParameters(), $this->request->getBodyParameters());
 }
Ejemplo n.º 3
0
 /**
  * Get a error report of an exception
  * @param Exception $exception
  * @param zibo\core\Request $request
  * @return string
  */
 private function getReport(Exception $exception, Request $request = null)
 {
     $report = 'Date: ' . date('d/m/Y H:i:s', time()) . "\n";
     if ($request) {
         $url = $request->getBasePath() . '/';
         $url .= implode('/', $request->getParameters());
         $report .= 'Request: ' . $url . "\n";
     }
     $user = SecurityManager::getInstance()->getUser();
     if ($user) {
         $report .= 'User: '******'User: anonymous';
     }
     $report .= "\n\nTrace:\n" . $this->getTrace($exception);
     return $report;
 }