예제 #1
0
 public function overrideRequest()
 {
     $request = $this->zibo->getRequest();
     $route = $request->getRoute();
     if (substr($route, 0, 4) == '/web') {
         return;
     }
     $request = new Request($request->getBaseUrl(), $request->getBaseUrl() . '/install', self::CONTROLLER_INSTALL, Dispatcher::ACTION_ASTERIX, $request->getParameters());
     $this->zibo->setRequest($request);
 }
예제 #2
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);
 }
 /**
  * Gets a request from the provided path for request chaining
  * @param string $path The path to route
  * @return zibo\core\Request|null A request if the path was found, null otherwise
  */
 protected function route($path)
 {
     $router = $this->zibo->getRouter();
     if (!$router) {
         return null;
     }
     return $router->getRequest($this->request->getBaseUrl(), $path);
 }
예제 #4
0
 /**
  * Invokes the wizard
  * @param zibo\core\Request $request The request
  * @param zibo\core\Response $response The response
  * @return null
  * @throws zibo\ZiboException when there are no steps in this wizard
  */
 public function invoke(Request $request, Response $response)
 {
     if (!$this->steps) {
         throw new ZiboException('This wizard does not contain any steps');
     }
     $this->request = $request;
     $this->response = $response;
     $this->currentStep = $this->getVariable(self::VARIABLE_CURRENT_STEP, $this->defaultStep);
     $step = $this->steps[$this->currentStep];
     $step->prepareForm();
     if ($this->isSubmitted()) {
         if ($this->getValue(self::BUTTON_CANCEL)) {
             $this->reset();
             if ($this->cancelUrl) {
                 $this->response->setRedirect($this->cancelUrl);
             } else {
                 $this->response->setRedirect($this->request->getBaseUrl());
             }
             return;
         }
         $nextStep = null;
         if ($this->getValue(self::BUTTON_PREVIOUS)) {
             $nextStep = $step->previous();
         } elseif ($this->getValue(self::BUTTON_NEXT)) {
             $nextStep = $step->next();
         } elseif ($this->getValue(self::BUTTON_FINISH)) {
             $nextStep = $step->finish();
         }
         if ($nextStep) {
             if (!$this->hasStep($nextStep)) {
                 throw new ZiboException('Cannot set the next step, invalid return value of step ' . $this->currentStep);
             }
             $this->setVariable(self::VARIABLE_CURRENT_STEP, $nextStep);
             $response->setRedirect($this->action);
         }
         if ($response->willRedirect()) {
             return;
         }
     }
     if (!$step->hasPrevious()) {
         $this->setIsDisabled(true, self::BUTTON_PREVIOUS);
     }
     if (!$step->hasNext()) {
         $this->setIsDisabled(true, self::BUTTON_NEXT);
     }
     if (!$step->hasFinish()) {
         $this->setIsDisabled(true, self::BUTTON_FINISH);
     }
     if (!$step->hasCancel()) {
         $this->setIsDisabled(true, self::BUTTON_CANCEL);
     }
     $view = $this->getView($step);
     if ($response->willRedirect()) {
         return;
     }
     $response->setView($view);
 }