0 follower

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
$metadata array Yiisoft\Queue\Message\Envelope

Public Methods

Hide inherited 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

Hide inherited properties

$metadata protected property
protected array $metadata null

Method Details

Hide inherited methods

__construct() public method

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;
}

            
fromData() public static method

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.',
    );
}

            
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;

            
getData() public method

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

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

            
getMessage() public method

public Yiisoft\Queue\Message\MessageInterface getMessage ( )

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

            
getMetadata() public method

public array getMetadata ( )

                final public function getMetadata(): array
{
    return $this->metadata;
}

            
getType() public method

public string getType ( )

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

            
withMetadata() public method

public static withMetadata ( array $metadata )
$metadata array

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