Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 755 Bytes

File metadata and controls

38 lines (27 loc) · 755 Bytes

Message Dispatcher

The domain message dispatcher is a utility trait. Its purpose is to dispatch a factorized message object using a object factory and a message bus.

API

dispatch(string $class, array $context = []): void

Dispatches a message object factorized from $class and $context.

Basic example

<?php

use MsgPhp\Domain\Message\MessageDispatchingTrait;

class MyMessage
{
    public $argument;

    public function __construct(string $argument)
    {
        $this->argument = $argument;
    }
}

class MyClass
{
    use MessageDispatchingTrait;

    public function doSomething(): void
    {
        $this->dispatch(MyMessage::class, ['argument' => 'value']);
    }
}