MCPcopy Create free account
hub / github.com/thinkjs/thinkjs / controller

Function controller

lib/extend/controller.js:234–242  ·  view source on GitHub ↗

* get controller instance * @param {String} name * @param {String} m

(name, m = this.ctx.module)

Source from the content-addressed store, hash-verified

232 * @param {String} m
233 */
234 controller(name, m = this.ctx.module) {
235 let mcls = think.app.controllers;
236 if (this.ctx.app.modules.length) {
237 mcls = think.app.controllers[m || 'common'] || {};
238 }
239 const Cls = mcls[name];
240 assert(Cls, `can not find controller: ${name}`);
241 return new Cls(this.ctx);
242 },
243 /**
244 * get service
245 * @param {String} name

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…