コード例 #1
0
ファイル: Test.php プロジェクト: miper/miper
 /**
  * 测试导航
  * @return [type] [description]
  */
 function testList()
 {
     $doc = new Miper_Docs_Processor(__DIR__ . '/Lib/', 'Delegate.php', array());
     $navs = $doc->getNavs();
     //var_dump($navs);
     $this->assertEquals('foo', 'foo');
 }
コード例 #2
0
ファイル: Processor.php プロジェクト: miper/miper
 private function handleClass($path)
 {
     $className = '';
     $fh = fopen($path, 'r');
     while (($line = fgets($fh)) !== false) {
         if (preg_match('#\\bclass\\s+([a-z][a-z0-9\\_]+)\\b#i', $line, $ms)) {
             $className = $ms[1];
             break;
         }
     }
     fclose($fh);
     if (!$className) {
         return;
     }
     $routers = array();
     // 虚构请求环境
     $_GET = array();
     $_POST = array();
     $_SERVER = array('REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '*');
     if (!self::$initedApp) {
         Miper_App::hook('pipe.request.before', function ($app, $func, $options) use(&$routers) {
             $routers[$app->pipeId][$func] = $options;
             return false;
         });
         Miper_App::hook('pipe.call.before', function ($app, $func, $options) use(&$routers) {
             if (!isset($routers[$app->pipeId][$func])) {
                 $routers[$app->pipeId][$func] = $options;
             }
             return false;
         });
         self::$initedApp = true;
     }
     require_once $path;
     $refClass = new ReflectionClass($className);
     $interNames = $refClass->getInterfaceNames();
     if (in_array('Miper_Delegate_Interface', $interNames)) {
         if (!self::$app) {
             $app = self::$app = Miper_App::getAppInstance();
         }
         $cls = new $className();
         $cls->delegate(self::$app);
     }
     $result = array();
     foreach ($routers as $route) {
         $result[] = array('method' => $route['request'][0], 'url' => $route['request'][1], 'class' => $route['call'][0], 'func' => $route['call'][1]);
     }
     return $result;
 }