Abstract Class Yiisoft\Queue\Message\Envelope
Protected Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $metadata | array | Yiisoft\Queue\Message\Envelope |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Queue\Message\Envelope | |
| fromData() | Envelopes cannot be created from raw data. Use {@see fromMessage()} to wrap an existing message instead. | 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 |
| getData() | Yiisoft\Queue\Message\Envelope | |
| getMessage() | Yiisoft\Queue\Message\Envelope | |
| getMetadata() | Yiisoft\Queue\Message\Envelope | |
| getType() | Yiisoft\Queue\Message\Envelope | |
| withMetadata() | Yiisoft\Queue\Message\Envelope |
Property Details
Method Details
| public mixed __construct ( Yiisoft\Queue\Message\MessageInterface $message, array $metadata ) | ||
| $message | Yiisoft\Queue\Message\MessageInterface | |
| $metadata | array | |
public function __construct(MessageInterface $message, array $metadata)
{
/** @var TMetadata */
$this->metadata = array_merge($message->getMetadata(), $metadata);
while ($message instanceof self) {
$message = $message->getMessage();
}
$this->message = $message;
}
Envelopes cannot be created from raw data. Use {@see fromMessage()} to wrap an existing message instead.
| public static static fromData ( string $type, mixed $data ) | ||
| $type | string | |
| $data | mixed | |
| throws | LogicException |
Always, since this method is not supported for envelopes. |
|---|---|---|
final public static function fromData(string $type, mixed $data): static
{
throw new LogicException(
'Envelopes cannot be created via "fromData()". Wrap an existing "MessageInterface" instance instead.',
);
}
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;
| public bool|int|float|string|array|null getData ( ) |
final public function getData(): bool|int|float|string|array|null
{
return $this->message->getData();
}
| public Yiisoft\Queue\Message\MessageInterface getMessage ( ) |
final public function getMessage(): MessageInterface
{
return $this->message;
}
| public string getType ( ) |
final public function getType(): string
{
return $this->message->getType();
}
| public static withMetadata ( array $metadata ) | ||
| $metadata | array | |
final public function withMetadata(array $metadata): static
{
return static::fromMessage($this->message->withMetadata($metadata));
}
Signup or Login in order to comment.