I divided my application in multiple smaller scopes through the prefixes used in routes. Now I would like to segregate the application more and have event listeners only listening to events from a specific prefix. I’m using CakePHP 4.
I tried to do this in the bootstrap.php, but there is no Request there yet. Same applies for the bootstrap()
method in Application.php.
I tried setting up a middleware, passing the Application and the EventManager::instance()
, but it seems that the singleton is different when using it from the one used in the end. Events dispatched in a controller will not be handled, even though I can see at registering they were registered.
A request is needed to check what the prefix is, so that I can conditionally load a set of configured EventListeners.
Maybe I’m too deep and lost in this dead end and missing another approach to this problem. Let me know if there is another way of making this possible!