webSocketSubmission = $webSocketSubmission; $this->config = $config; } public function afterSave(Entity $entity): void { if (!$this->config->get('useWebSocket')) { return; } if (!$entity->isNew()) { return; } $userId = $entity->get('userId'); if (!$userId) { return; } $this->webSocketSubmission->submit('newNotification', $userId); } }