mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-30 18:46:01 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			33 lines
		
	
	
		
			846 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			846 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 'use strict';
 | |
| 
 | |
| const validator = require('validator');
 | |
| const plugins = require('../../plugins');
 | |
| 
 | |
| const hooksController = module.exports;
 | |
| 
 | |
| hooksController.get = function (req, res) {
 | |
| 	const hooks = [];
 | |
| 	Object.keys(plugins.loadedHooks).forEach(function (key, hookIndex) {
 | |
| 		const 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 ? validator.escape(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 });
 | |
| };
 |