File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
system/Commands/Utilities Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 13
13
14
14
use CodeIgniter \CLI \BaseCommand ;
15
15
use CodeIgniter \CLI \CLI ;
16
+ use CodeIgniter \Commands \Utilities \Routes \ControllerFinder ;
17
+ use CodeIgniter \Commands \Utilities \Routes \ControllerMethodReader ;
18
+ use CodeIgniter \Router \RouteCollection ;
16
19
use Config \Services ;
17
20
18
21
/**
@@ -101,6 +104,10 @@ public function run(array $params)
101
104
}
102
105
}
103
106
107
+ if ($ collection ->shouldAutoRoute ()) {
108
+ $ tbody = array_merge ($ tbody , $ this ->getAutoRoutes ($ collection ));
109
+ }
110
+
104
111
$ thead = [
105
112
'Method ' ,
106
113
'Route ' ,
@@ -109,4 +116,31 @@ public function run(array $params)
109
116
110
117
CLI ::table ($ tbody , $ thead );
111
118
}
119
+
120
+ private function getAutoRoutes (RouteCollection $ collection ): array
121
+ {
122
+ $ defaultNamespace = $ collection ->getDefaultNamespace ();
123
+ $ finder = new ControllerFinder ($ defaultNamespace );
124
+ $ reader = new ControllerMethodReader ($ defaultNamespace );
125
+
126
+ $ tbody = [];
127
+
128
+ foreach ($ finder ->find () as $ class ) {
129
+ $ output = $ reader ->read (
130
+ $ class ,
131
+ $ collection ->getDefaultController (),
132
+ $ collection ->getDefaultMethod ()
133
+ );
134
+
135
+ foreach ($ output as $ item ) {
136
+ $ tbody [] = [
137
+ 'auto ' ,
138
+ $ item ['route ' ],
139
+ $ item ['handler ' ],
140
+ ];
141
+ }
142
+ }
143
+
144
+ return $ tbody ;
145
+ }
112
146
}
You can’t perform that action at this time.
0 commit comments