Handler¶
-
class
DreamCommerce\
Handler
¶
It’s an object for handling automatic messages from AppStore. It’s event-based which allows to easily bind many handlers to the particular event (eg. for installation handler, it’s possible to bind database storing, cache purging, etc).
methods¶
-
DreamCommerce\Handler::
__construct
($entrypoint, $clientId, $secret, $appStoreSecret)¶ Class constructor
Parameters: - $entrypoint (string) – shop URL - in case of webapi/rest is not a part of URL, it will be automatically appended
- $clientId (string) – application ID
- $secret (string) – API key
- $appStoreSecret (string) – secret code
-
DreamCommerce\Handler::
subscribe
($event, $handler)¶ Subscribes a handler to the chosen event.
Parameters: - $event (string) – event type for handling by handler
- $handler (Callable) – a handler to call when subscribed event is fired.
$handler
will be called with one argument of event params. If handler returns false value, event propagation is stopped.
Available
$event
values:install
- an application is being installed in shopuninstall
- an application is being uninstalledbilling_install
- installation paymentbilling_subscription
- subscription payment
-
DreamCommerce\Handler::
unsubscribe
($event, $handler = null)¶ Unsubscribes from event handling.
Parameters: - $event (string) – event type for handling by handler
- $handler (null|Callable) – if is
null
, all handlers are unbound. Specifying particular handler, leaves alone all except chosen.
Available
$event
values:install
- an application is being installed in shopuninstall
- an application is being uninstalledbilling_install
- installation paymentbilling_subscription
- subscription payment