0

Abstract Class Yiisoft\Queue\Message\Envelope

InheritanceYiisoft\Queue\Message\Envelope
ImplementsYiisoft\Queue\Message\MessageInterface
SubclassesYiisoft\Queue\Message\DelayEnvelope, Yiisoft\Queue\Message\IdEnvelope, Yiisoft\Queue\Middleware\FailureHandling\FailureEnvelope, Yiisoft\Queue\Stubs\DummyEnvelope

Protected Properties

Hide inherited properties

Property Type Description Defined By
$meta array Yiisoft\Queue\Message\Envelope

Public Methods

Hide inherited methods

Method Description Defined By
__construct() Yiisoft\Queue\Message\Envelope
fromMessage() Creates an envelope for the given message, restoring the envelope's own parameters from the message metadata. Yiisoft\Queue\Message\Envelope
fromPayload() Envelopes cannot be created from a raw payload. Use {@see fromMessage()} to wrap an existing message instead. Yiisoft\Queue\Message\Envelope
getMessage() Yiisoft\Queue\Message\Envelope
getMeta() Yiisoft\Queue\Message\Envelope
getPayload() Yiisoft\Queue\Message\Envelope
getType() Yiisoft\Queue\Message\Envelope
withMeta() Yiisoft\Queue\Message\Envelope

Property Details

Hide inherited properties

$meta protected property
protected array $meta null

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( Yiisoft\Queue\Message\MessageInterface $message, array $meta )
$message Yiisoft\Queue\Message\MessageInterface
$meta array

                public function __construct(MessageInterface $message, array $meta)
{
    /** @var TMeta */
    $this->meta = array_merge($message->getMeta(), $meta);
    while ($message instanceof self) {
        $message = $message->getMessage();
    }
    $this->message = $message;
}

            
fromMessage() public abstract static method

Creates an envelope for the given message, restoring the envelope's own parameters from the message metadata.

public abstract static static fromMessage ( Yiisoft\Queue\Message\MessageInterface $message )
$message Yiisoft\Queue\Message\MessageInterface

The message to create an envelope for.

                abstract public static function fromMessage(MessageInterface $message): static;

            
fromPayload() public static method

Envelopes cannot be created from a raw payload. Use {@see fromMessage()} to wrap an existing message instead.

public static static fromPayload ( string $type, mixed $payload )
$type string
$payload mixed
throws LogicException

Always, since this method is not supported for envelopes.

                final public static function fromPayload(string $type, mixed $payload): static
{
    throw new LogicException(
        'Envelopes cannot be created via "fromPayload()". Wrap an existing "MessageInterface" instance instead.',
    );
}

            
getMessage() public method

public Yiisoft\Queue\Message\MessageInterface getMessage ( )

                final public function getMessage(): MessageInterface
{
    return $this->message;
}

            
getMeta() public method

public array getMeta ( )

                final public function getMeta(): array
{
    return $this->meta;
}

            
getPayload() public method

public bool|int|float|string|array|null getPayload ( )

                final public function getPayload(): bool|int|float|string|array|null
{
    return $this->message->getPayload();
}

            
getType() public method

public string getType ( )

                final public function getType(): string
{
    return $this->message->getType();
}

            
withMeta() public method

public static withMeta ( array $meta )
$meta array

                final public function withMeta(array $meta): static
{
    return static::fromMessage($this->message->withMeta($meta));
}