Repository navigation
Internals Response Registry SenderRegistry
Framework Internals · Subsystem overview · Developer guide
Source: awt_src/classes/response/registry/SenderRegistry.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.
use response\interface\SenderInterface;class SenderRegistrySource description (behavioral corrections are recorded in Known discrepancies):
Open/Closed: add new types by registering a new SenderInterface. No existing class needs modification.
Declarations below preserve visibility, type, default and modifiers exactly. A typed property without an initializer remains uninitialized until its constructor or another method assigns it. Mutable fields belong to this instance unless marked static; readonly fields can be initialized once. Constructor-promoted properties are also listed below.
| Member | Declaration | Purpose or source contract |
|---|---|---|
| $map | private array $map = []; |
@var array<string, SenderInterface> mime → sender |
| Method | Signature |
|---|---|
| register | public function register(SenderInterface $sender): void |
| resolve | public function resolve(string $mime): SenderInterface |
| has | public function has(string $mime): bool |
public function register(SenderInterface $sender): void| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$sender |
SenderInterface $sender |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
State writes: $this->map[strtolower($mime)].
Implementation, validation guards and interaction order
public function register(SenderInterface $sender): void
{
foreach ($sender->supportedMimes() as $mime) {
$this->map[strtolower($mime)] = $sender;
}
}public function resolve(string $mime): SenderInterface| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$mime |
string $mime |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
@throws \RuntimeException when no sender handles the given MIME.
Return expressions (including local callbacks): $this->map[$key]; $sender.
Explicit exceptions: \RuntimeException. The guards in the implementation below show when each is raised; exceptions from collaborators also propagate unless caught.
Implementation, validation guards and interaction order
/**
* @throws \RuntimeException when no sender handles the given MIME.
*/
public function resolve(string $mime): SenderInterface
{
$key = strtolower(strtok($mime, ';')); // strip parameters like "; charset=utf-8"
if (isset($this->map[$key])) {
return $this->map[$key];
}
// Partial match on type group (e.g. "image/*").
[$group] = explode('/', $key);
foreach ($this->map as $registeredMime => $sender) {
if (str_starts_with($registeredMime, $group . '/')) {
return $sender;
}
}
throw new \RuntimeException("No sender registered for MIME type '$mime'.");
}public function has(string $mime): bool| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$mime |
string $mime |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
Return expressions (including local callbacks): true; false.
Failure handling catches \RuntimeException.
Implementation, validation guards and interaction order
public function has(string $mime): bool
{
try {
$this->resolve($mime);
return true;
} catch (\RuntimeException) {
return false;
}
}AWT Framework Wiki · Home · Installation Guide · Developer Guide · Framework Internals
Philosophy · Architecture · Known discrepancies · Verification
Installation Guide
Developer Guide
- Learning sequence
- First package
- Package structure
- Lifecycle
- Runtimes
- Events and objects
- Routing and controllers
- Views and resources
- Database and models
- Storage and caching
- Configuration and CLI
- Responses and errors
- Extension points
Framework Internals
- Architecture
- Bootstrap
- Packages
- Runtime
- Events and context
- Objects
- HTTP routing and controllers
- Rendering
- Blade integration
- Database
- Models
- Storage and caching
- Settings
- CLI
- Identity and sessions
- Responses
- Errors
- Complete source inventory
Documentation notes