mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 19:15:58 +01:00 
			
		
		
		
	closes #6854
This commit is contained in:
		
							
								
								
									
										32
									
								
								src/controllers/admin/hooks.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/controllers/admin/hooks.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,32 @@ | ||||
| 'use strict'; | ||||
|  | ||||
| var plugins = require('../../plugins'); | ||||
|  | ||||
| var hooksController = module.exports; | ||||
|  | ||||
| hooksController.get = function (req, res) { | ||||
| 	var hooks = []; | ||||
| 	Object.keys(plugins.loadedHooks).forEach(function (key, hookIndex) { | ||||
| 		var current = { | ||||
| 			hookName: key, | ||||
| 			methods: [], | ||||
| 			index: 'hook-' + hookIndex, | ||||
| 			count: plugins.loadedHooks[key].length, | ||||
| 		}; | ||||
|  | ||||
| 		plugins.loadedHooks[key].forEach(function (hookData, methodIndex) { | ||||
| 			current.methods.push({ | ||||
| 				id: hookData.id, | ||||
| 				priority: hookData.priority, | ||||
| 				method: hookData.method ? hookData.method.toString() : 'No plugin function!', | ||||
| 				index: hookIndex + '-code-' + methodIndex, | ||||
| 			}); | ||||
| 		}); | ||||
| 		hooks.push(current); | ||||
| 	}); | ||||
|  | ||||
| 	hooks.sort((a, b) => b.count - a.count); | ||||
|  | ||||
| 	res.render('admin/advanced/hooks', { hooks: hooks }); | ||||
| }; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user