Remove extension hooks from project config. Args: extension_id: ID of extension to unregister
(self, extension_id: str)
| 3190 | self.save_project_config(config) |
| 3191 | |
| 3192 | def unregister_hooks(self, extension_id: str): |
| 3193 | """Remove extension hooks from project config. |
| 3194 | |
| 3195 | Args: |
| 3196 | extension_id: ID of extension to unregister |
| 3197 | """ |
| 3198 | # Always remove from installed list (Feedback from review) |
| 3199 | self.unregister_extension(extension_id) |
| 3200 | |
| 3201 | config = self.get_project_config() |
| 3202 | |
| 3203 | if not isinstance(config, dict): |
| 3204 | config = {} |
| 3205 | # We don't save yet, as there are no hooks to unregister, |
| 3206 | # but unregister_extension above might have already saved a normalized config. |
| 3207 | return |
| 3208 | |
| 3209 | if "hooks" not in config or not isinstance(config["hooks"], dict): |
| 3210 | return |
| 3211 | |
| 3212 | # Remove hooks for this extension |
| 3213 | for hook_name in list(config["hooks"].keys()): |
| 3214 | hook_list = config["hooks"][hook_name] |
| 3215 | if not isinstance(hook_list, list): |
| 3216 | config["hooks"][hook_name] = [] |
| 3217 | continue |
| 3218 | config["hooks"][hook_name] = [ |
| 3219 | h |
| 3220 | for h in hook_list |
| 3221 | if isinstance(h, dict) and h.get("extension") != extension_id |
| 3222 | ] |
| 3223 | |
| 3224 | # Clean up empty hook arrays |
| 3225 | config["hooks"] = { |
| 3226 | name: hooks for name, hooks in config["hooks"].items() if hooks |
| 3227 | } |
| 3228 | |
| 3229 | self.save_project_config(config) |
| 3230 | |
| 3231 | def get_hooks_for_event(self, event_name: str) -> List[Dict[str, Any]]: |
| 3232 | """Get all enabled hooks for a specific event, sorted by priority ascending. |