/** * {@inheritdoc} */ public function on($eventName, callable $eventHandler) { $eventName = 'on' . $eventName; $this->application->sendCommand('setObjectEventListener', [$this->lazarusObjectId, $eventName], function ($result) { // Ok, the event listener created }); if (!array_key_exists($eventName, $this->eventHandlers)) { $this->eventHandlers[$eventName] = []; } $this->eventHandlers[$eventName][] = $eventHandler; }