For the complete documentation index, see llms.txt. This page is also available as Markdown.

Aggregate Query Handlers

DDD PHP

Read Aggregate Introduction sections first to get more details about Aggregates.

Aggregate Query Action

Aggregate actions are defined using public method (non-static). Ecotone will ensure loading in order to execute the query method.

#[Aggregate]
class Ticket
{
    #[Identifier]
    private Uuid $ticketId;
    private string $assignedTo;
       
    #[QueryHandler("ticket.get_assigned_person")]
    public function getAssignedTo(): string
    {
       return $this->assignedTo;
    }
}

And then we call it from Query Bus:

$this->commandBus->sendWithRouting(
    "ticket.get_assigned_person",
    // We provide instance of Ticket aggregate using metadata 
    metadata: ["aggregate.id" => $ticketId]
)

Last updated

Was this helpful?