File tree 1 file changed +42
-0
lines changed
src/Symfony/Component/Messenger/Transport/Serialization
1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <[email protected] >
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony \Component \Messenger \Transport \Serialization ;
13
+
14
+ use Symfony \Component \Messenger \Envelope ;
15
+ use Symfony \Component \Messenger \Transport \Serialization \Serializer as MessengerSerializer ;
16
+ use Symfony \Component \Serializer \Encoder \JsonEncoder ;
17
+ use Symfony \Component \Serializer \Encoder \XmlEncoder ;
18
+ use Symfony \Component \Serializer \Normalizer \ObjectNormalizer ;
19
+ use Symfony \Component \Serializer \Serializer as SymfonySerializer ;
20
+
21
+ class SimpleSerializer implements EncoderInterface, DecoderInterface
22
+ {
23
+ private $ serializer ;
24
+
25
+ public function __construct ()
26
+ {
27
+ $ encoders = array (new XmlEncoder (), new JsonEncoder ());
28
+ $ normalizers = array (new ObjectNormalizer ());
29
+ $ serializer = new SymfonySerializer ($ normalizers , $ encoders );
30
+ $ this ->serializer = new MessengerSerializer ($ serializer );
31
+ }
32
+
33
+ public function decode (array $ encodedEnvelope ): Envelope
34
+ {
35
+ return $ this ->serializer ->decode ($ encodedEnvelope );
36
+ }
37
+
38
+ public function encode (Envelope $ envelope ): array
39
+ {
40
+ return $ this ->serializer ->encode ($ envelope );
41
+ }
42
+ }
You can’t perform that action at this time.
0 commit comments