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


PHP Dispatcher::getControllerName方法代码示例

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


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

示例1: beforeDispatch

 /**
  * This action is executed before execute any action in the application
  *
  * @param Event $event
  * @param Dispatcher $dispatcher
  */
 public function beforeDispatch(Event $event, Dispatcher $dispatcher)
 {
     $auth = $this->session->get('auth');
     if (!$auth) {
         $role = 'Guests';
     } else {
         $role = 'Users';
     }
     $controller = $dispatcher->getControllerName();
     $action = $dispatcher->getActionName();
     $acl = $this->getAcl();
     $allowed = $acl->isAllowed($role, $controller, $action);
     if ($allowed != Acl::ALLOW) {
         $dispatcher->forward(array('controller' => 'errors', 'action' => 'show401'));
         $this->session->destroy();
         return false;
     }
 }
开发者ID:serviceCuCu91,项目名称:PhalconOauth2RESTfulServer,代码行数:24,代码来源:.AuthenticationPlugin.php

示例2: _exec

 private static function _exec()
 {
     define('CURRENT_MODULE', Dispatcher::getModuleName());
     define('CURRENT_CONTROLLER', Dispatcher::getControllerName());
     define('CURRENT_ACTION', Dispatcher::getActionName());
     $controllerName = CURRENT_CONTROLLER;
     $moduleName = CURRENT_MODULE;
     if ($moduleName) {
         $className = sprintf('controller\\%s\\%s', $moduleName, $controllerName);
     } else {
         $className = sprintf("controller\\%s", $controllerName);
     }
     //-----请求日志------//
     $params = array();
     $log = array('request_id' => REQUEST_ID, 'uri' => $_SERVER['REQUEST_URI'], 'class' => array('module' => CURRENT_MODULE, 'controller' => CURRENT_CONTROLLER, 'action' => CURRENT_ACTION), 'method' => Request::method(), 'params' => array_merge($params, Request::gets(), Request::posts()), 'stream' => Request::stream(), 'cookie' => Request::cookies(), 'ip' => Request::ip());
     C::log($log);
     if (!class_exists($className)) {
         throw new \RuntimeException('类不存在');
     }
     try {
         $obj = new \ReflectionClass($className);
         if ($obj->isAbstract()) {
             throw new \RuntimeException('抽象类不可被实例化');
         }
         $class = $obj->newInstance();
         //前置操作
         if ($obj->hasMethod(CURRENT_ACTION . 'Before')) {
             $beforeMethod = $obj->getMethod(CURRENT_ACTION . 'Before');
             if ($beforeMethod->isPublic() && !$beforeMethod->isStatic()) {
                 $beforeMethod->invoke($class);
             }
         }
         $method = $obj->getMethod(CURRENT_ACTION . 'Action');
         if ($method->isPublic() && !$method->isStatic()) {
             $method->invoke($class);
         }
         //后置操作
         if ($obj->hasMethod(CURRENT_ACTION . 'After')) {
             $afterMethod = $obj->getMethod(CURRENT_ACTION . 'After');
             if ($afterMethod->isPublic() && !$afterMethod->isStatic()) {
                 $afterMethod->invoke($class);
             }
         }
     } catch (\Exception $e) {
         self::_halt($e);
     }
 }
开发者ID:zer0131,项目名称:OneFox,代码行数:47,代码来源:Onefox.php

示例3: fromDispatcher

 /**
  * Add new elements in breadcrumbs corresponding to request dispatcher : controllerName, actionName, parameters
  * @param Dispatcher $dispatcher the request dispatcher
  * @return \Ajax\bootstrap\html\HtmlBreadcrumbs
  */
 public function fromDispatcher($dispatcher, $startIndex = 0)
 {
     $this->startIndex = $startIndex;
     $params = $dispatcher->getParams();
     $action = $dispatcher->getActionName();
     $items = array($dispatcher->getControllerName());
     if (\sizeof($params) > 0 || \strtolower($action) != "index") {
         $items[] = $action;
         foreach ($params as $p) {
             if (\is_object($p) === false) {
                 $items[] = $p;
             }
         }
     }
     return $this->addItems($items);
 }
开发者ID:jcheron,项目名称:phalcon-jquery-website,代码行数:21,代码来源:HtmlBreadcrumb.php

示例4: fromDispatcher

 /**
  * set the active page corresponding to request dispatcher : controllerName, actionName, parameters and $urlMask
  * @param Dispatcher $dispatcher the request dispatcher
  * @return \Ajax\bootstrap\html\HtmlPagination
  */
 public function fromDispatcher($dispatcher)
 {
     $items = array($dispatcher->getControllerName(), $dispatcher->getActionName());
     $items = array_merge($items, $dispatcher->getParams());
     $url = implode("/", $items);
     if ($this->urlMask === "%page%") {
         $this->urlMask = preg_replace("/[0-9]/", "%page%", $url);
     }
     for ($index = $this->from; $index <= $this->to; $index++) {
         if ($this->getUrl($index) == $url) {
             $this->setActive($index);
             break;
         }
     }
     return $this;
 }
开发者ID:aleboisselier,项目名称:phalcon-jquery,代码行数:21,代码来源:HtmlPagination.php


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