add Hooks
This commit is contained in:
+8
-1
@@ -16,11 +16,13 @@ public class GlobalControllerAdvice {
|
||||
|
||||
private final SettingService settingService;
|
||||
private final com.sisvietnamvn.web.service.MenuService menuService;
|
||||
private final com.sisvietnamvn.web.hook.HookManager hookManager;
|
||||
private final PathMatchingResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
|
||||
|
||||
public GlobalControllerAdvice(SettingService settingService, com.sisvietnamvn.web.service.MenuService menuService) {
|
||||
public GlobalControllerAdvice(SettingService settingService, com.sisvietnamvn.web.service.MenuService menuService, com.sisvietnamvn.web.hook.HookManager hookManager) {
|
||||
this.settingService = settingService;
|
||||
this.menuService = menuService;
|
||||
this.hookManager = hookManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,6 +66,11 @@ public class GlobalControllerAdvice {
|
||||
return getWidgets("footer");
|
||||
}
|
||||
|
||||
@ModelAttribute("hookManager")
|
||||
public com.sisvietnamvn.web.hook.HookManager getHookManager() {
|
||||
return hookManager;
|
||||
}
|
||||
|
||||
@ModelAttribute("themeModPrimaryColor")
|
||||
public String getThemeModPrimaryColor() {
|
||||
return settingService.getValue("theme_mod_primaryColor", "#007bff");
|
||||
|
||||
@@ -50,13 +50,18 @@ public class HookManager {
|
||||
/**
|
||||
* Executes an action and returns an empty string.
|
||||
* This is useful for invoking actions directly within Thymeleaf templates
|
||||
* (e.g., <th:block th:text="${@hookManager.doActionAndReturn('wp_head')}"></th:block>).
|
||||
* (e.g., <th:block th:text="${hookManager.doActionAndReturn('wp_head')}"></th:block>).
|
||||
*/
|
||||
public String doActionAndReturn(String hookName, Object... args) {
|
||||
doAction(hookName, args);
|
||||
return "";
|
||||
}
|
||||
|
||||
public String doActionAndReturn(String hookName) {
|
||||
doAction(hookName);
|
||||
return "";
|
||||
}
|
||||
|
||||
// --- Filters ---
|
||||
|
||||
public <T> void addFilter(String hookName, FilterCallback<T> callback, int priority) {
|
||||
|
||||
Reference in New Issue
Block a user