当前位置: 首页>>代码示例>>PHP>>正文


PHP Dispatcher::getHandlerClass方法代码示例

本文整理汇总了PHP中Phalcon\Mvc\Dispatcher::getHandlerClass方法的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher::getHandlerClass方法的具体用法?PHP Dispatcher::getHandlerClass怎么用?PHP Dispatcher::getHandlerClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phalcon\Mvc\Dispatcher的用法示例。


在下文中一共展示了Dispatcher::getHandlerClass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: beforeExecuteRoute

 /**
  * Execute before the router so we can determine if this is a private controller, and must be authenticated, or a
  * public controller that is open to all.
  *
  * @param Dispatcher $dispatcher
  * @return boolean
  */
 public function beforeExecuteRoute(Dispatcher $dispatcher)
 {
     $controllerName = $dispatcher->getControllerName();
     // this is not namespaced
     $controllerName = $dispatcher->getHandlerClass();
     // this IS namespaced
     // Only check permissions on private controllers
     // By virtue of extending BaseAuth, this is a private controller
     // Get the current identity
     $identity = $this->auth->getIdentity();
     // If there is no identity available the user is redirected to index/index
     if (!is_array($identity)) {
         $this->flashSession->warning('Please sign in.');
         $dispatcher->forward(array('controller' => 'session', 'action' => 'login'));
         return false;
     }
     //$this->flash->notice( \Dsc\Lib\Debug::dump( $identity ) );
     // Check if the user have permission to the current option
     $actionName = $dispatcher->getActionName();
     if (!$this->acl->isAllowed($identity['profile'], $controllerName, $actionName)) {
         $this->flash->warning('You don\'t have access to: ' . $controllerName . ' : ' . $actionName);
         if ($this->acl->isAllowed($identity['profile'], $controllerName, 'index')) {
             $dispatcher->forward(array('controller' => $controllerName, 'action' => 'index'));
         } else {
             $dispatcher->forward(array('controller' => 'User_Control', 'action' => 'index'));
         }
         return false;
     }
 }
开发者ID:fenghuilee,项目名称:writepress,代码行数:36,代码来源:BaseAuth.php

示例2: beforeExecuteRoute

 /**
  * @param Event         $event
  * @param MvcDispatcher $dispatcher
  */
 public function beforeExecuteRoute(Event $event, MvcDispatcher $dispatcher)
 {
     if ($dispatcher->getNamespaceName() !== $dispatcher->getDefaultNamespace()) {
         /** @var MvcView $view */
         $view = $dispatcher->getDI()->get('view');
         if ($view->isDisabled()) {
             return;
         }
         $viewPathParts = array_values(array_diff(explode('\\', strtolower($dispatcher->getHandlerClass())), explode('\\', strtolower($dispatcher->getDefaultNamespace()))));
         $viewPathParts[] = $dispatcher->getActionName();
         $view->setLayout($viewPathParts[0]);
         $view->pick(implode(DIRECTORY_SEPARATOR, $viewPathParts));
     }
 }
开发者ID:mamuz,项目名称:phalcon-application,代码行数:18,代码来源:View.php

示例3: beforeDispatch

 public function beforeDispatch(\Phalcon\Events\Event $event, Dispatcher $dispatcher)
 {
     $id = $this->session->get(self::SESSION_USER_ID);
     $sessionKey = $this->session->get(self::SESSION_KEY);
     $user = $this->getCurrentUser();
     if ($id && $user) {
         if (!$user->validateSessionKey($sessionKey)) {
             $this->session->destroy();
             $this->response->redirect('');
             return false;
         }
         // Allow access when logged in
     } else {
         if ($dispatcher->getHandlerClass() === 'AuthController' && $dispatcher->getActionName() === 'login') {
             // Permit the login action when not logged in
         } else {
             // Handle everything with /auth/login for guests
             $dispatcher->forward(array('controller' => 'auth', 'action' => 'login'));
         }
     }
 }
开发者ID:stecman,项目名称:passnote,代码行数:21,代码来源:Security.php


注:本文中的Phalcon\Mvc\Dispatcher::getHandlerClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。