plugin-event-handler

Register Symfony GenericEvent handlers for HyperV plugin events in getHooks().

6|Updated Jun 8, 2017
One-click install
npx skills add https://github.com/myadmin-plugins/hyperv-vps --skill plugin-event-handler
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: plugin-event-handler
Source: https://github.com/myadmin-plugins/hyperv-vps/tree/main/.claude/skills/plugin-event-handler
Command: npx skills add https://github.com/myadmin-plugins/hyperv-vps --skill plugin-event-handler

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Adds or modifies event handler methods in src/Plugin.php for the Detain\MyAdminHyperv namespace using Symfony GenericEvent. Use when user says 'add event', 'hook into', 'register listener', 'plugin event', or extends Plugin.php functionality with new event subscriptions. References getSoapClientParams() and getHooks() patterns. Do NOT use for standalone bin/ scripts or bin/async/ scripts.

Core Features & Use Cases

  • Public static function handlers for HyperV events
  • Hooks registration in getHooks() to ensure firing
  • Guard against non-HYPERV events and maintain compatibility with existing Plugin
  • Safe logging and propagation control to coordinate with other listeners

Quick Start

Use the plugin event handler to extend Plugin.php by defining a new public static method that accepts a GenericEvent and registering it in getHooks().

Frequently Asked Questions about plugin-event-handler

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I register Symfony event listeners in a PHP plugin?

To hook into HyperV module events, define a public static method accepting a Symfony GenericEvent and register it inside the getHooks() method in src/Plugin.php. This ensures your custom handler fires when the corresponding module event occurs.

How do I handle a vps.activate event in my PHP plugin?

To handle a vps.activate event, create a public static function in Plugin.php that accepts a GenericEvent. You must guard the logic with get_service_define('HYPERV') to ensure it only processes HyperV service activations.

How do I stop other listeners from running after my event handler executes?

To stop other listeners from running, call stopPropagation on the GenericEvent after your handler completes its work. This coordinates listener execution and prevents subsequent hooks from interfering with the processed event.

Can I use this event handler approach for standalone bin/ scripts?

No, this event handler approach is strictly for extending src/Plugin.php within the Detain\MyAdminHyperv namespace. Do not use it for standalone bin/ scripts or bin/async/ scripts.

How do I guard my HyperV event handler against non-HyperV events?

Guard your HyperV event handler by checking get_service_define('HYPERV') at the start of your static method. This maintains compatibility with the existing Plugin and ensures the logic only processes relevant events.