Browse Source

增加可选api生成文档

kingang 6 years ago
parent
commit
efc92f71a9
1 changed files with 19 additions and 10 deletions
  1. 19 10
      application/admin/command/Api.php

+ 19 - 10
application/admin/command/Api.php

@@ -81,16 +81,25 @@ class Api extends Command
                 throw new Exception("Please make sure opcache already enabled, Get help:https://forum.fastadmin.net/d/1321");
             }
         }
-
-        $controllerDir = $moduleDir . Config::get('url_controller_layer') . DS;
-        $files = new \RecursiveIteratorIterator(
-            new \RecursiveDirectoryIterator($controllerDir),
-            \RecursiveIteratorIterator::LEAVES_ONLY
-        );
-
-        foreach ($files as $name => $file) {
-            if (!$file->isDir() && $file->getExtension() == 'php') {
-                $filePath = $file->getRealPath();
+        //控制器名
+        $controller = $input->getOption('controller') ?: '';
+        if(!$controller) {
+            $controllerDir = $moduleDir . Config::get('url_controller_layer') . DS;
+            $files = new \RecursiveIteratorIterator(
+                new \RecursiveDirectoryIterator($controllerDir),
+                \RecursiveIteratorIterator::LEAVES_ONLY
+            );
+
+            foreach ($files as $name => $file) {
+                if (!$file->isDir() && $file->getExtension() == 'php') {
+                    $filePath = $file->getRealPath();
+                    $classes[] = $this->get_class_from_file($filePath);
+                }
+            }
+        }
+        else{
+            foreach ($controller as $index => $item) {
+                $filePath=$moduleDir . Config::get('url_controller_layer') . DS .$item.'.php';
                 $classes[] = $this->get_class_from_file($filePath);
             }
         }