events

Implements and registers Symfony EventDispatcher subscribers for OrangeHRM domain and kernel events.

Updated Jul 23, 2026
One-click install
npx skills add https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone --skill events-snow-gift111
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: events
Source: https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone/tree/main/.agents/skills/events
Command: npx skills add https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone --skill events-snow-gift111

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? OrangeHRM's event system has no automatic subscriber discovery, so developers frequently write subscribers that never fire, dispatch events with mismatched names, or struggle to understand listener priority and propagation. This Skill documents the exact conventions for defining events, writing subscribers, and registering them so decoupled pub-sub works correctly across plugins. ## Core Features & Use Cases - Event Definition Conventions: Covers the <Plugin>Events constant-holder class, Event-extending payload classes, naming rules, and dispatching from services via EventDispatcherTrait. - Subscriber Authoring & Registration: Explains AbstractEventSubscriber, getSubscribedEvents() priority arrays, and the mandatory addSubscriber() call in <Plugin>PluginConfiguration::initialize(). - Framework vs Domain Events: Maps Symfony KernelEvents listeners (authentication, authorization, exception handling) versus OHRM business events like EmployeeSavedEvent and LeaveApply, including priority ordering and stopPropagation(). - Use Case: You need to react whenever an employee is saved. Use this Skill to create a subscriber listening to EmployeeEvents::EMPLOYEE_SAVED, register it in your plugin configuration, and debug why it might not fire. ## Quick Start Ask the agent to create a new domain event and a subscriber that reacts to it in an OrangeHRM plugin, following the events skill conventions.

Frequently Asked Questions about events

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

FAQPage Schema
How do I create a custom event in OrangeHRM?

Create a constant in your plugin's `<Plugin>Events.php` class with a dotted lowercase value, then create an event class extending `OrangeHRM\Framework\Event\Event` that carries the payload via constructor and getters. Dispatch it from a service using `$this->getEventDispatcher()->dispatch(new YourEvent($data), YourEvents::YOUR_EVENT)`.

How do I register an event subscriber in an OrangeHRM plugin?

Subscribers must be explicitly registered in the plugin's `<Plugin>PluginConfiguration::initialize()` method by calling `$this->getEventDispatcher()->addSubscriber(new YourSubscriber())`. There is no automatic filesystem-based discovery, so without this call the subscriber never fires.

Why is my Symfony event subscriber not firing in OrangeHRM?

The most common cause is a missing `addSubscriber()` call in the plugin configuration. Also verify the event name string matches exactly (use the constant on both sides), the plugin is registered and loaded, and no higher-priority subscriber called `stopPropagation()`.

What is the difference between KernelEvents and OrangeHRM domain events?

KernelEvents are Symfony framework events (request, controller, response, exception) fired on every HTTP request and used by core subscribers like authentication and authorization. OHRM domain events like `EmployeeSavedEvent` are dispatched by services to signal business actions that feature plugins react to.

How does event listener priority work in Symfony EventDispatcher?

Each listener is registered as `[methodName, priority]` where higher numbers run first and the default is 0. OrangeHRM uses large gaps (e.g., 100000 for authentication, 80000 for authorization) so new listeners can be inserted between existing ones without renumbering.

When should I use stopPropagation on an event?

Call `$event->stopPropagation()` only when a subscriber has fully handled the event and later listeners must not run, such as when an exception subscriber has already produced a response. For domain events it is usually wrong, since multiple plugins may independently react to the same business event.