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


PHP Lib::api方法代码示例

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


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

示例1: execute

 public function execute()
 {
     $api = Lib::api('admin', array('response' => 'return', 'format' => 'php'));
     $type = Req::get('type');
     if (!is_callable(array($api, $type))) {
         return Lib::redirect('error');
     }
     $result = $api->{$type}();
     $options = array('view' => 'admin');
     $ref = Req::post('ref');
     if (!$result['state']) {
         if (!empty($ref)) {
             $options['ref'] = $ref;
         }
     } else {
         $segments = explode('/', base64_decode(urldecode($ref)));
         $base = array_shift($segments);
         $type = array_shift($segments);
         $subtype = array_shift($segments);
         if (!empty($type)) {
             $options['type'] = $type;
         }
         if (!empty($subtype)) {
             $options['subtype'] = $subtype;
         }
     }
     Lib::redirect('admin', $options);
 }
开发者ID:jasonrey,项目名称:project-test-report,代码行数:28,代码来源:admin.php

示例2: route

 public function route($segments = array())
 {
     $name = array_shift($segments);
     $method = array_shift($segments);
     $api = Lib::api($name);
     if (!is_callable(array($api, $method))) {
         return Lib::api()->fail();
     }
     $api->{$method}($segments);
 }
开发者ID:jasonrey,项目名称:lab-page,代码行数:10,代码来源:api.php

示例3: route

 public static function route()
 {
     $prefix = '/' . Config::getBaseFolder();
     $requesturi = $_SERVER['REQUEST_URI'];
     if (substr($requesturi, 0, strlen($prefix)) == $prefix) {
         $requesturi = substr($requesturi, strlen($prefix));
     }
     $requesturi = trim($requesturi, '/');
     $requestSegments = explode('?', $requesturi);
     $segments = explode('/', $requestSegments[0]);
     if ($segments[0] !== 'index.php') {
         Lib::load('router');
         foreach (Router::getRouters() as $router) {
             if (is_string($router->allowedRoute) && $segments[0] !== $router->allowedRoute) {
                 continue;
             }
             if (is_array($router->allowedRoute) && !in_array($segments[0], $router->allowedRoute)) {
                 continue;
             }
             $router->decode($segments);
         }
     }
     // Check for API call
     if (Req::hasget('api')) {
         $apiName = Req::get('api');
         $action = Req::get('action');
         $api = Lib::api($apiName);
         if (!is_callable(array($api, $action))) {
             return Lib::api()->fail();
         }
         return $api->{$action}();
     }
     // Check for controller
     if (Req::hasget('controller')) {
         $controllerName = Req::get('controller');
         $action = Req::get('action');
         $controller = Lib::controller($controllerName);
         if (!is_callable(array($controller, $action))) {
             return $controller->execute();
         }
         return $controller->{$action}();
     }
     $viewname = Req::get('view');
     if (empty($viewname)) {
         $viewname = 'error';
     }
     return Lib::view($viewname)->display();
 }
开发者ID:jasonrey,项目名称:project-test-report,代码行数:48,代码来源:lib.php


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