Skip to content

Internals Context Events RespondContextEvent

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

context\events\RespondContextEvent

Framework Internals · Subsystem overview · Developer guide

Source: awt_src/classes/context/events/RespondContextEvent.php · Snapshot 8411f4287706.

Context carries the current package root, name and ID. Context events let consumers request or replace that information through the dispatcher.

Imports and dependencies

use context\Context;
use event\interfaces\IEvent;
use event\interfaces\IEventListener;

RespondContextEvent

Declaration and architectural role

final class RespondContextEvent implements IEventListener

Constants, enum cases, traits and properties

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
$context public Context $context; Used by __construct(), handle().
Constructor-promoted public function __construct(Context $context) Initialized from the constructor argument; default expression is evaluated when the argument is omitted.

Method index

Method Signature
__construct public function __construct(Context $context)
handle public function handle(IEvent $event): array

__construct

Source line 12

public function __construct(Context $context)

Parameters

Parameter Type, modifiers and default Purpose
$context Context $context Package context object or package name according to the declared type.

State writes: $this->context.

Implementation, validation guards and interaction order
public function __construct(Context $context)
    {
        $this->context = $context;
    }

handle

Source line 16

public function handle(IEvent $event): array

Parameters

Parameter Type, modifiers and default Purpose
$event IEvent $event Event object; its name selects listeners and its bundle carries their payload.

Return expressions (including local callbacks): ["context" => $context, "event" => $event, "type" => "respond"].

Implementation, validation guards and interaction order
public function handle(IEvent $event): array
    {
        $context = $event->bundle()['context'];
        $context->setContext($this->context);
        return ["context" => $context, "event" => $event, "type" => "respond"];
    }

Related types

Clone this wiki locally