0 follower

Final Class Yiisoft\Queue\Middleware\FailureHandling\FailureEnvelope

InheritanceYiisoft\Queue\Middleware\FailureHandling\FailureEnvelope » Yiisoft\Queue\Message\Envelope
ImplementsYiisoft\Queue\Message\MessageInterface

Protected Properties

Hide inherited properties

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

Constants

Hide inherited constants

Constant Value Description Defined By
META_FAILURE 'yii-failure' Yiisoft\Queue\Middleware\FailureHandling\FailureEnvelope

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( Yiisoft\Queue\Message\MessageInterface $message, array $failureMetadata = [] )
$message Yiisoft\Queue\Message\MessageInterface
$failureMetadata array

                public function __construct(MessageInterface $message, array $failureMetadata = [])
{
    $this->failureMetadata = $failureMetadata === []
        ? self::getFailureMetadataFromMessage($message)
        : ArrayHelper::merge(
            self::getFailureMetadataFromMessage($message),
            $failureMetadata,
        );
    parent::__construct($message, [
        self::META_FAILURE => $this->failureMetadata,
    ]);
}

            
fromData() public static method

Defined in: Yiisoft\Queue\Message\Envelope::fromData()

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 static method

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

                public static function fromMessage(MessageInterface $message): static
{
    return new self(
        $message,
        self::getFailureMetadataFromMessage($message),
    );
}

            
getData() public method
public mixed getData ( )

                final public function getData(): mixed
{
    return $this->message->getData();
}

            
getFailureMetadata() public method

public array getFailureMetadata ( )

                public function getFailureMetadata(): array
{
    return $this->failureMetadata;
}

            
getFailureMetadataValue() public method

public mixed getFailureMetadataValue ( string $key, mixed $default null )
$key string
$default mixed

                public function getFailureMetadataValue(string $key, mixed $default = null): mixed
{
    return $this->failureMetadata[$key] ?? $default;
}

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