@@ -41,12 +41,13 @@ public function run(array $params)
4141 $ methods = $ this ->_getMethodsFromCLass ($ class );
4242
4343 foreach ($ methods as $ key => $ value ) {
44- if (strpos ( $ value, ' __ ' ) ! == false ) {
44+ if ($ value[ 0 ] == ' _ ' ) {
4545 unset($ methods [$ key ]);
4646 }
4747 }
4848
4949 $ class = (mb_substr ($ class , 0 , 1 ) !== '\\' ) ? '\\' . $ class : $ class ;
50+
5051 $ this ->_checkClassNamespace ($ api , $ class , $ methods );
5152 }
5253
@@ -99,8 +100,15 @@ private function _checkApiModel(): ?\Daycry\RestServer\Entities\ApiEntity
99100
100101 private function _getMethodsFromCLass ($ namespace ): array
101102 {
102- $ methods = get_class_methods ($ namespace );
103- return ($ methods ) ? $ methods : [];
103+ $ f = new \ReflectionClass ($ namespace );
104+ $ methods = array ();
105+ foreach ($ f ->getMethods () as $ m ) {
106+ if ($ m ->class == $ namespace ) {
107+ $ methods [] = $ m ->name ;
108+ }
109+ }
110+
111+ return $ methods ;
104112 }
105113
106114 private function _checkClassNamespace (\Daycry \RestServer \Entities \ApiEntity $ api , string $ class , array $ methods = [])
@@ -117,10 +125,9 @@ private function _checkClassNamespace(\Daycry\RestServer\Entities\ApiEntity $api
117125 }
118126 // @codeCoverageIgnoreEnd
119127
120- $ namespace ->fill (array ( 'checked_at ' => (new DateTime ('now ' ))->format ('Y-m-d H:i:s ' ) ));
121- $ namespaceModel ->save ($ namespace );
122-
123128 if ($ namespace ->controller == $ class ) {
129+ $ namespace ->fill (array ( 'checked_at ' => (new DateTime ('now ' ))->format ('Y-m-d H:i:s ' ), 'methods ' => $ methods ) );
130+ $ namespaceModel ->save ($ namespace );
124131 $ found = true ;
125132 break ;
126133 }
@@ -130,7 +137,7 @@ private function _checkClassNamespace(\Daycry\RestServer\Entities\ApiEntity $api
130137
131138 if (!$ found ) {
132139 $ namespace = new \Daycry \RestServer \Entities \NamespaceEntity ();
133- $ namespace = $ namespace ->setController ($ class );//->setMethods($methods);
140+ $ namespace = $ namespace ->setController ($ class );
134141 $ namespace ->methods = $ methods ;
135142 $ namespace ->api_id = $ api ->id ;
136143 $ namespaceModel ->save ($ namespace );
0 commit comments