* execute action * @param {String} controller * @param {String} actionName * @param {String} m
(controller, actionName, m)
| 268 | * @param {String} m |
| 269 | */ |
| 270 | action(controller, actionName, m) { |
| 271 | let instance = controller; |
| 272 | // if controller is an controller instance, ignore invoke controller method |
| 273 | if (helper.isString(controller)) { |
| 274 | instance = this.controller(controller, m); |
| 275 | } |
| 276 | let promise = Promise.resolve(); |
| 277 | if (instance.__before) { |
| 278 | promise = Promise.resolve(instance.__before()); |
| 279 | } |
| 280 | return promise.then(data => { |
| 281 | if (data === false) return false; |
| 282 | let method = `${actionName}Action`; |
| 283 | if (!instance[method]) { |
| 284 | method = '__call'; |
| 285 | } |
| 286 | if (instance[method]) return instance[method](); |
| 287 | }).then(data => { |
| 288 | if (data === false) return false; |
| 289 | if (instance.__after) return instance.__after(); |
| 290 | return data; |
| 291 | }); |
| 292 | }, |
| 293 | /** |
| 294 | * download |
| 295 | * @param {String} filepath |
nothing calls this directly
no test coverage detected