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

Function explicitRoutes

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

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

Callers 1

extractFunction · 0.85

Calls 4

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

Tested by

no test coverage detected