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

Function routeHandler

src/resolution/frameworks/codeigniter.ts:219–230  ·  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

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