Skip to content

Internals Response Senders JsSender

Stefan Crkvenjakov edited this page Oct 7, 2026 · 1 revision

response\senders\JsSender

Framework Internals · Subsystem overview · Developer guide

Source: awt_src/classes/response/senders/JsSender.php · Snapshot 8411f4287706.

Response builds status, headers and data/file payloads, chooses a MIME sender, and emits HTTP output. JSON arrays are wrapped in a status/message/data envelope.

JsSender

Declaration and architectural role

class JsSender extends AbstractSender

Constants, enum cases, traits and properties

No own constants, enum cases, traits or property declarations. Inherited members are documented on the parent reference page.

Method index

Method Signature
supportedMimes public function supportedMimes(): array
send public function send(mixed $payload, int $status, array $headers): void

supportedMimes

Source line 7

public function supportedMimes(): array

Return expressions (including local callbacks): ['application/javascript', 'text/javascript'].

Implementation, validation guards and interaction order
public function supportedMimes(): array
    {
        return ['application/javascript', 'text/javascript'];
    }

send

Source line 12

public function send(mixed $payload, int $status, array $headers): void

Parameters

Parameter Type, modifiers and default Purpose
$payload mixed $payload Operation input; the exact use, validation and propagation are shown in the implementation trace.
$status int $status Operation input; the exact use, validation and propagation are shown in the implementation trace.
$headers array $headers Operation input; the exact use, validation and propagation are shown in the implementation trace.

Delegates to emitStatus(), emitContentType(), emitHeaders(), streamFile().

Implementation, validation guards and interaction order
public function send(mixed $payload, int $status, array $headers): void
    {
        $this->emitStatus($status);
        $this->emitContentType('application/javascript');
        $this->emitHeaders($headers);

        if (is_string($payload) && file_exists($payload)) {
            $this->streamFile($payload);
        } else {
            echo (string) $payload;
        }
    }

Related types

Clone this wiki locally