Events

Events are dispatched in an instance of the Application class in specific moments. They can be classified as 4 main types by event name creation. The technology behind the event system is explained in the next chapter, see Architecture. You can easily build an event name by using static helper methods from the Jtl\Connector\Core\Definition\Event class.

2. Core controller events

This event type is connector core events related. It can be used if you want to override data which is sent by connector core to a client or in opposite direction.

Event examples:

  • Jtl\Connector\Core\Event\FeaturesEvent
  • Jtl\Connector\Core\Event\BoolEvent
  • Jtl\Connector\Core\Event\ModelEvent

How to create name for this event?

use Jtl\Connector\Core\Definition\Action;
use Jtl\Connector\Core\Definition\Controller;
use Jtl\Connector\Core\Definition\Event;

Event::createCoreEventName(Controller::CONNECTOR, Action::FEATURES, Event::AFTER);

3. Handle events

Handle events are fired before and after a specific request is ‘handled’ by the Core or by the endpoint (depends on implementation).

Events:

  • Jtl\Connector\Core\Event\RequestEvent (before handle)
  • Jtl\Connector\Core\Event\ResponseEvent (after handle)

How to create name for this event?

use Jtl\Connector\Core\Definition\Action;
use Jtl\Connector\Core\Definition\Controller;
use Jtl\Connector\Core\Definition\Event;

Event::createHandleEventName(Controller::PRODUCT, Action::PULL, Event::PULL);

4. RPC event

There are two RPC events in the Core that you can subscribe. They are called before serialization and before response is sent.

Event: Jtl\Connector\Core\Event\RpcEvent

How to create name for this event?

use Jtl\Connector\Core\Definition\Event;

Event::createRpcEventName(Event::BEFORE);