Currently, event bindings are supported using a callback.
Ready::class => [
['action' => 'init', 'transformer' => function () {
$ready = null;
if (!self::$initRan) {
$ready = new Ready();
self::$initRan = true;
}
return $ready;
}]
],
This tends to be overly terse, and require calls like this in cases where you want to encapsulate the logic:
$saleTransformerCallback = fn($orderId, $orderData) => $this->container->get(
SaleTriggeredTransformer::class
)->getSaleTriggeredEvent($orderId, $orderData);
SaleTriggered::class => [
['action' => 'action', 'transformer' => $saleTransformerCallback],
],
It would be much nicer if it were possible to do this, instead:
SaleTriggered::class => [
['action' => 'action', 'transformer' => SaleTriggeredTransformer::class],
],
Would likely require that we create an EventTransformer interface, and we'd need to update the loader to support it, but once it's all set, this would really clean up and simplify event bindings.
Currently, event bindings are supported using a callback.
Ready::class => [ ['action' => 'init', 'transformer' => function () { $ready = null; if (!self::$initRan) { $ready = new Ready(); self::$initRan = true; } return $ready; }] ],This tends to be overly terse, and require calls like this in cases where you want to encapsulate the logic:
It would be much nicer if it were possible to do this, instead:
SaleTriggered::class => [ ['action' => 'action', 'transformer' => SaleTriggeredTransformer::class], ],Would likely require that we create an
EventTransformerinterface, and we'd need to update the loader to support it, but once it's all set, this would really clean up and simplify event bindings.