Handlers and Services
Last updated
Was this helpful?
Last updated
Was this helpful?
and are two distinct concepts, but they were designed together and are being used together. Specifically, services make use of handlers. Handlers, however, can be freely used in other contexts as well.
Handlers are that also implement a get_type
method. For example, handlers for the are of the logging type.
Services are meant to be central hubs (i.e., singleton instances) for performing certain actions. It's not mandatory, but we designed all of our services to delegate the responsibility of performing the actions to a handler. For example, a service inheriting the class always performs the actions with the same handler whereas a service inheriting the class needs to be instructed which registered handler to use.
The handlers are also prime candidates for . There are 3 traits that the foundations module comes with:
-- using objects will call the output
method of their registered handlers.
-- using objects will call the run
method of their registered handlers
-- using objects will call the reset
method of their registered handlers.
For example, a implementing the and using the OutputHandlersTrait
mentioned above will automagically call the output
method of all its registered handlers also implementing the OutputtableInterface
when the service's own output
method is called. Pretty neat, huh?