You can implement your own handler using the RetailCrm\Api\Interfaces\HandlerInterface.
RetailCrm\Api\Handler\AbstractHandler provides boilerplate code for the chain of responsibility.
AbstractHandler::next method will call next handler in the chain. You can safely use return parent::next() in your code
while using AbstractHandler.
Most of the information about how handlers operate can be found in the chain of responsibility pattern explanation. There are some specific details about handlers in the client. Client will pass desired dependencies to the handler if handler implements one of those interfaces:
- Any request handler
RetailCrm\Api\Interfaces\PsrFactoriesAwareInterfacewill inject PSR-17 factories into the handler.
- Any response handler
RetailCrm\Api\Interfaces\SerializerAwareInterfacewill inject aliip/serializerinstance into the handler.RetailCrm\Api\Interfaces\ApiExceptionFactoryAwareInterfacewill inject aLiip\Serializer\SerializerInterfaceinstance into the handler.RetailCrm\Api\Interfaces\EventDispatcherAwareInterfacewill inject aPsr\EventDispatcher\EventDispatcherInterfaceinstance into the handler.
All of those interfaces above have the corresponding implementation traits in the RetailCrm\Api\Traits namespace.
For example, RetailCrm\Api\Interfaces\EventDispatcherAwareInterface implementation can be found in the
RetailCrm\Api\Traits\EventDispatcherAwareTrait trait.
Handlers can be used in the both chains just like callback handlers (see "using a predefined hander").