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


PHP CFactory::instance方法代码示例

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


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

示例1: run

 function run()
 {
     try {
         $this->_filter->routeStartup();
         //路由开始
         $action = $this->_router->route();
         $action = $this->_filter->routeShutdown($action);
         //路由关闭
         $action = $this->_filter->dispatchStartup($action);
         //方法调度
         $method = $action->_method;
         $action->{$method}();
         $this->_filter->dispatchShutdown();
         //方法调度完成
         $action->response();
         $this->_filter->endReturn();
         //返回结果
     } catch (CException $e) {
         //异常处理
         if ($e->exceptionType == 'biz') {
             //业务逻辑异常--抛到业务层处理
             $actionclass = $e->exActionMethod . '_Action';
             $action = CFactory::instance($actionclass, $e->params, true, true);
             $method = $action->_method;
             $action->{$method}();
             $action->response();
             $this->_filter->endReturn();
             //返回结果
         } else {
             //核心异常--直接抛出异常
             throw new Exception($e);
         }
     }
 }
开发者ID:9618211,项目名称:simple-php-framework,代码行数:34,代码来源:CApp.php

示例2: route

 function route($controller = null, $action = null, $method = null)
 {
     if (!$controller && !$action) {
         $paths = $this->_url_path->getRequestPaths();
         if (sizeof($paths) <= 1) {
             if ($paths[0] == '') {
                 $controller = 'index';
                 $action = 'index';
             } else {
                 if (substr($paths[0], 0, 1) == '~') {
                     $controller = 'index';
                     $action = 'index';
                 } else {
                     $controller = $paths[0];
                     $action = 'index';
                 }
             }
         } else {
             $start = 0;
             if (substr($paths[$start], 0, 1) == '~') {
                 $controller = 'index';
                 $action = 'index';
                 $method = substr($paths[$start], 1);
                 $start += 1;
             } elseif (substr($paths[$start + 1], 0, 1) == '~') {
                 $controller = $paths[$start];
                 $action = 'index';
                 $method = substr($paths[$start + 1], 1);
                 $start += 2;
             } elseif (isset($paths[$start + 2]) && substr($paths[$start + 2], 0, 1) == '~') {
                 $controller = $paths[$start];
                 $action = $paths[$start + 1];
                 $method = substr($paths[$start + 2], 1);
                 $start += 3;
             } else {
                 $controller = $paths[$start];
                 $action = $paths[$start + 1];
                 $start += 2;
             }
         }
     }
     $actionName = $controller . '_' . $action . '_Action';
     $action = CFactory::instance($actionName, array(), true, false);
     if (isset($method)) {
         $action->_method = $method;
     }
     $action->_actionName = $actionName;
     return $action;
 }
开发者ID:9618211,项目名称:simple-php-framework,代码行数:49,代码来源:CRouter.php


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