From efc92f71a902fba0df7c184f156310848da51aa3 Mon Sep 17 00:00:00 2001 From: kingang <443721842@qq.com> Date: Sat, 21 Dec 2019 15:10:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=AF=E9=80=89api?= =?UTF-8?q?=E7=94=9F=E6=88=90=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/command/Api.php | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/application/admin/command/Api.php b/application/admin/command/Api.php index bfd9dce1..c2ce2f2c 100644 --- a/application/admin/command/Api.php +++ b/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"); } } + //控制器名 + $controller = $input->getOption('controller') ?: ''; + if(!$controller) { + $controllerDir = $moduleDir . Config::get('url_controller_layer') . DS; + $files = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($controllerDir), + \RecursiveIteratorIterator::LEAVES_ONLY + ); - $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(); + 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); } }