<?php

namespace onespace\tools\rabbit\helpers;

use Yii;

/** Helper trait to handle returning SSE scopes in correct format. */
trait SseControllerHelper {

    public function asScopes(array $scopes): \yii\web\Response {
        $scopesValue = join("|", $scopes);
        Yii::$app->response->headers->add("X-Scopes", $scopesValue);
        Yii::info("Attaching scopes: " . $scopesValue);
        Yii::$app->response->setStatusCode(204);

        return Yii::$app->response;
    }
}
