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