drupal-events
Skill71 starsChanged 7 months agoMITView on GitHub
Drupal event subscribers — Symfony events (PSR-14), KernelEvents, services.yml tags, and hooks vs events decision guide.
In this repository35 other files it gives its agents.
- ddev-expertSkill
- docker-localSkill
- drupal-accessSkill
- drupal-cachingSkill
- drupal-composerSkill
- drupal-configSkill
- drupal-contrib-mgmtSkill
- drupal-debuggingSkill
- drupal-drushSkill
- drupal-dttSkill
- drupal-entity-apiSkill
- drupal-fieldsSkill
- drupal-form-ajaxSkill
- drupal-form-alterSkill
- drupal-form-apiSkill
- drupal-form-validationSkill
- drupal-hooksSkill
- drupal-htmxSkill
- drupal-javascriptSkill
- drupal-kernelSkill
- drupal-menusSkill
- drupal-migrationsSkill
- drupal-paragraphsSkill
- drupal-pluginsSkill
- drupal-queriesSkill
- drupal-renderSkill
- drupal-routesSkill
- drupal-search-apiSkill
- drupal-securitySkill
- drupal-servicesSkill
- drupal-stateSkill
- drupal-taxonomySkill
- drupal-twigSkill
- drupal-unitSkill
- SKILL.mdSkill
The file
Files
Drupal Event Subscribers
Example (Best Practice)
// src/EventSubscriber/MyEventSubscriber.php
namespace Drupal\my_module\EventSubscriber;
use Drupal\Core\Session\AccountProxyInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
final class MyEventSubscriber implements EventSubscriberInterface {
public function __construct(
private readonly AccountProxyInterface $currentUser,
) {}
public static function getSubscribedEvents(): array {
return [
// Note: Higher priority runs earlier. Default is 0.
KernelEvents::REQUEST => ['onRequest', 100],
];
}
public function onRequest(RequestEvent $event): void {
if (!$event->isMainRequest()) {
return;
}
if (!$this->currentUser->isAuthenticated()) {
return;
}
// Example: log or modify behavior for authenticated users.
}
}Register in services.yml
services:
my_module.my_event_subscriber:
class: Drupal\my_module\EventSubscriber\MyEventSubscriber
arguments: ['@current_user']
tags:
- { name: event_subscriber }Common Events
| Event | Constant | When |
| Request | KernelEvents::REQUEST | Every request |
| Response | KernelEvents::RESPONSE | Before response sent |
| Terminate | KernelEvents::TERMINATE | After response sent |
| Exception | KernelEvents::EXCEPTION | On uncaught exception |
Generate with Drush
drush generate event-subscriber --answers='{
"module": "my_module",
"class": "MyEventSubscriber",
"event": "kernel.request"
}'Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

