Event System Overview
Introduction
WNCMS event docs are grouped by domain. Add new hooks to the matching group page when introducing them in core.
Event Groups
Event Registration
In a Service Provider
php
namespace App\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
public function boot()
{
Event::listen('wncms.frontend.users.register.after', function ($user) {
// Your logic here
});
}
}Using Event Listeners
php
namespace App\Listeners;
class SendWelcomeEmail
{
public function handle($user)
{
// Send welcome email
}
}Register in EventServiceProvider:
php
protected $listen = [
'wncms.frontend.users.register.after' => [
SendWelcomeEmail::class,
],
];Best Practices
- Use references when runtime mutation is required (
&$param). - Keep hook names aligned with the naming standard.
- Wrap listener logic in error handling when side effects are non-critical.
- Keep hook docs updated in this folder in the same task.
- Sync zh-CN and zh-TW docs when structure changes.