Recently, I had to decorate the drupal state service to do something when a site goes into maintenance mode.
When trying to figure out how to do this, I found a really helpful post describing how to decorate the state, by Previous Next. This post was already quite old, and I could not get it to work with the just the information in that post.
First of all, we need to define the service in the
The key to making this work is to having a
decorates key in the service definition.
That makes the new service wrap around the configured service.
Now all that is needed, is to create the state decorator.
The injected service (
RebelNotification) here can now sound an alarm so that the rebels know about the maintenance mode event.