コード例 #1
0
 /**
  * Gets the method name from the action name. If the action name is *, a method name will
  * be looked via the parameters with a fallback on indexAction.
  * @param Controller $controller The controller to invoke
  * @param string $actionName The name of the action
  * @param array $parameters The parameters of the request
  * @return null
  * @throws zibo\ZiboException when no invokable action is found
  */
 protected function processActionName(Controller $controller, &$actionName, &$parameters)
 {
     $this->passRequestParameters = true;
     $action = null;
     if ($actionName == Dispatcher::ACTION_ASTERIX && $parameters) {
         $action = $parameters[0];
     }
     $widgetParameters = $this->widget->getRequestParameters();
     if ($action && ($widgetParameters != Dispatcher::ACTION_ASTERIX && !in_array($action, $widgetParameters))) {
         $actionName = Dispatcher::ACTION_INDEX;
         $parameters = array();
         $this->passRequestParameters = false;
     }
     parent::processActionName($this->widget, $actionName, $parameters);
 }
コード例 #2
0
ファイル: Zibo.php プロジェクト: BGCX261/zibo-svn-to-git
 /**
  * Dispatch the request to the action of the controller
  * @return null
  */
 private function dispatch()
 {
     if (!$this->dispatcher) {
         $this->dispatcher = new Dispatcher(new ObjectFactory());
     }
     while ($this->request != null) {
         $this->eventManager->runEvent(self::EVENT_PRE_DISPATCH);
         if ($this->request == null) {
             continue;
         }
         try {
             $chainedRequest = $this->dispatcher->dispatch($this->request, $this->response);
             $this->setRequest($chainedRequest);
         } catch (Exception $e) {
             $this->eventManager->runEvent(self::EVENT_ERROR, $e);
             $this->setRequest(null);
         }
         $this->eventManager->runEvent(self::EVENT_POST_DISPATCH);
     }
 }
コード例 #3
0
ファイル: Module.php プロジェクト: BGCX261/zibo-svn-to-git
 /**
  * Sets an unauthorized status code to the response and dispatch to the authentication form
  * @return null
  */
 private function showAuthenticationForm()
 {
     $zibo = Zibo::getInstance();
     $request = $zibo->getRequest();
     $response = $zibo->getResponse();
     $securityManager = SecurityManager::getInstance();
     $user = $securityManager->getUser();
     if ($user) {
         // already logged in, show blank page with error message
         $response->addMessage(new Message(self::TRANSLATION_ERROR_FORBIDDEN, Message::TYPE_ERROR));
         $response->setStatusCode(Response::STATUS_CODE_FORBIDDEN);
         $response->setView(new BaseView());
         return;
     }
     // not logged in, show authentication form
     $response->addMessage(new Message(self::TRANSLATION_ERROR_UNAUTHORIZED, Message::TYPE_ERROR));
     $authenticator = $securityManager->getAuthenticator();
     if ($authenticator instanceof HttpAuthenticator) {
         $response->addHeader(Response::HEADER_AUTHENTICATE, $authenticator->getAuthenticateHeader());
         $response->setStatusCode(Response::STATUS_CODE_UNAUTHORIZED);
     } else {
         $response->setStatusCode(Response::STATUS_CODE_FORBIDDEN);
     }
     $dispatcher = $zibo->getDispatcher();
     if (!$dispatcher) {
         $dispatcher = new Dispatcher(new ObjectFactory());
     }
     $baseUrl = $request->getBaseUrl();
     $basePath = $baseUrl . Request::QUERY_SEPARATOR . self::ROUTE_AUTHENTICATION;
     $controller = self::CONTROLLER_AUTHENTICATION;
     $request = new Request($baseUrl, $basePath, $controller, Dispatcher::ACTION_ASTERIX);
     $dispatcher->dispatch($request, $response);
 }