$this->context =
$context +
[self::MESSENGER_SERIALIZATION_CONTEXT => true
];
} public static function create(): self
{ if (!
class_exists(SymfonySerializer::
class)) { throw new LogicException(sprintf('The "%s" class requires Symfony\'s Serializer component. Try running "composer require symfony/serializer" or use "%s" instead.', __CLASS__, PhpSerializer::
class));
} $encoders =
[new XmlEncoder(),
new JsonEncoder()];
$normalizers =
[new DateTimeNormalizer(),
new ArrayDenormalizer(),
new ObjectNormalizer()];
$serializer =
new SymfonySerializer($normalizers,
$encoders);
return new self($serializer);
} public function decode(array
$encodedEnvelope): Envelope
{ if (empty($encodedEnvelope['body'
]) ||
empty($encodedEnvelope['headers'
])) { throw new MessageDecodingFailedException('Encoded envelope should have at least a "body" and some "headers", or maybe you should implement your own serializer.'
);
} if (empty($encodedEnvelope['headers'
]['type'
])) {