From 84fb64d67fee0399c13afa79f2d37e67b35605fc Mon Sep 17 00:00:00 2001
From: phatpnh <phat.pnh2019@gmail.com>
Date: Wed, 2 Nov 2022 14:57:29 +0700
Subject: [PATCH] Fix bug CSM

---
 components/Utils.php | 66 +++++++++++++++++++++++---------------------
 1 file changed, 34 insertions(+), 32 deletions(-)

diff --git a/components/Utils.php b/components/Utils.php
index 54cd80e..0d6f997 100644
--- a/components/Utils.php
+++ b/components/Utils.php
@@ -33,41 +33,43 @@ class Utils
                     foreach ($verbs as $verb) {
                         foreach ($rule->controller as $plural => $single) {
                             $controllerClassName = "app\controllers\\" . Inflector::id2camel($single) . "Controller";
-                            $classObject = new $controllerClassName($single, false);
-                            $controllerKey = str_replace("\\", '.', $controllerClassName);
-                            $controllerName = Inflector::id2camel($single) . "Controller";
-                            if (!isset($routes[$controllerKey])) {
-                                $routes[$controllerKey] = [
+                            if(class_exists($controllerClassName)){
+                                $classObject = new $controllerClassName($single, false);
+                                $controllerKey = str_replace("\\", '.', $controllerClassName);
+                                $controllerName = Inflector::id2camel($single) . "Controller";
+                                if (!isset($routes[$controllerKey])) {
+                                    $routes[$controllerKey] = [
+                                        'id' => null,
+                                        'applicationName' => $service,
+                                        'aliasName' => $controllerName,
+                                        'serviceClassName' => $controllerKey,
+                                        'servicePath' => "/" . $plural,
+                                        'description' => 'CĂ¡c APIs cá»§a ' . $controllerName,
+                                        'listSmtmServiceMethods' => []
+                                    ];
+                                }
+                                $methodName = Inflector::id2camel($action) . ucfirst($single);
+                                $routes[$controllerKey]['listSmtmServiceMethods'][] = [
                                     'id' => null,
-                                    'applicationName' => $service,
-                                    'aliasName' => $controllerName,
-                                    'serviceClassName' => $controllerKey,
-                                    'servicePath' => "/" . $plural,
-                                    'description' => 'CĂ¡c APIs cá»§a ' . $controllerName,
-                                    'listSmtmServiceMethods' => []
+                                    'aliasName' => "/" . implode("/", $pattern ? [
+                                            $plural,
+                                            $pattern
+                                        ] : [
+                                            $plural
+                                        ]),
+                                    'serviceMethodName' => $methodName,
+                                    'serviceMethodType' => $verb,
+                                    'description' => "MĂ´ tả method $verb - $methodName",
+                                    'fullPath' => "/services/" . implode("/", $pattern ? [
+                                            $service,
+                                            $plural,
+                                            $pattern
+                                        ] : [
+                                            $service,
+                                            $plural
+                                        ]),
                                 ];
                             }
-                            $methodName = Inflector::id2camel($action) . ucfirst($single);
-                            $routes[$controllerKey]['listSmtmServiceMethods'][] = [
-                                'id' => null,
-                                'aliasName' => "/" . implode("/", $pattern ? [
-                                        $plural,
-                                        $pattern
-                                    ] : [
-                                        $plural
-                                    ]),
-                                'serviceMethodName' => $methodName,
-                                'serviceMethodType' => $verb,
-                                'description' => "MĂ´ tả method $verb - $methodName",
-                                'fullPath' => "/services/" . implode("/", $pattern ? [
-                                        $service,
-                                        $plural,
-                                        $pattern
-                                    ] : [
-                                        $service,
-                                        $plural
-                                    ]),
-                            ];
                         }
                     }
 
-- 
GitLab