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

Function explicitRoutes

src/resolution/frameworks/codeigniter.ts:163–188  ·  view source on GitHub ↗

`$route['pattern'] = 'controller/method'`, verb-scoped or not, and the default controller at `/`.

(filePath: string, safe: string)

Source from the content-addressed store, hash-verified

161
162/** `$route['pattern'] = 'controller/method'`, verb-scoped or not, and the default controller at `/`. */
163function explicitRoutes(filePath: string, safe: string): { nodes: Node[]; references: UnresolvedRef[] } {
164 const nodes: Node[] = [];
165 const references: UnresolvedRef[] = [];
166 const now = Date.now();
167 const root = filePath.slice(0, filePath.indexOf('application/'));
168 ROUTE_RE.lastIndex = 0;
169 let m: RegExpExecArray | null;
170 while ((m = ROUTE_RE.exec(safe)) !== null) {
171 const [, pattern, verb, handler] = m;
172 if (pattern === '404_override' || pattern === 'translate_uri_dashes' || !handler) continue;
173 const line = lineAt(safe, m.index);
174 const routePath = pattern === 'default_controller' ? '/' : `/${pattern!.replace(/^\/+/, '')}`;
175 const route = routeNode(filePath, line, (verb ?? 'ANY').toUpperCase(), routePath, now);
176 nodes.push(route);
177 references.push({
178 fromNodeId: route.id,
179 referenceName: `${ROUTE_REF}${root}|${handler}:${awaitedName(handler!)}`,
180 referenceKind: 'references',
181 line,
182 column: 0,
183 filePath,
184 language: 'php',
185 });
186 }
187 return { nodes, references };
188}
189
190/** A method by name on a class, its own or one it inherits. PHP doesn't mind the case. */
191function methodOf(cls: Node, name: string, context: ResolutionContext): Node | null {

Callers 1

extractFunction · 0.85

Calls 5

lineAtFunction · 0.90
routeNodeFunction · 0.85
awaitedNameFunction · 0.85
pushMethod · 0.80
execMethod · 0.65

Tested by

no test coverage detected