MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / routeHandler

Function routeHandler

src/resolution/frameworks/codeigniter.ts:221–232  ·  view source on GitHub ↗

What `controller/method/$1` serves: the first run of segments that names a controller, then the method after it.

(root: string, uri: string, context: ResolutionContext)

Source from the content-addressed store, hash-verified

219
220/** What `controller/method/$1` serves: the first run of segments that names a controller, then the method after it. */
221function routeHandler(root: string, uri: string, context: ResolutionContext): Node | null {
222 const { controllers } = classTable(context);
223 const segments = uri.split('/').filter(Boolean);
224 const lower = segments.map((segment) => segment.toLowerCase());
225 for (let i = lower.length; i > 0; i--) {
226 const classes = controllers.get(lower.slice(0, i).join('/'));
227 if (!classes) continue;
228 const cls = classes.find((c) => c.filePath.startsWith(root)) ?? classes[0]!;
229 return handlerIn(cls, segments, i, context);
230 }
231 return null;
232}
233
234/** The file the `$this->load->view('users/list')` on this line loads: the caller's module's, another module's, or the app's. */
235function viewFile(ref: UnresolvedRef, context: ResolutionContext): Node | null {

Callers 1

resolveFunction · 0.85

Calls 5

classTableFunction · 0.85
handlerInFunction · 0.85
mapMethod · 0.80
getMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected