File tree 1 file changed +41
-0
lines changed
src/Symfony/Component/Messenger/Transport/Serialization
1 file changed +41
-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 \Serializer \Encoder \JsonEncoder ;
16
+ use Symfony \Component \Serializer \Encoder \XmlEncoder ;
17
+ use Symfony \Component \Serializer \Normalizer \ObjectNormalizer ;
18
+ use Symfony \Component \Serializer \Serializer as SymfonySerializer ;
19
+
20
+ class SimpleSerializer implements EncoderInterface, DecoderInterface
21
+ {
22
+ private $ serializer ;
23
+
24
+ public function __construct ()
25
+ {
26
+ $ encoders = array (new XmlEncoder (), new JsonEncoder ());
27
+ $ normalizers = array (new ObjectNormalizer ());
28
+ $ serializer = new SymfonySerializer ($ normalizers , $ encoders );
29
+ $ this ->serializer = new Serializer ($ serializer );
30
+ }
31
+
32
+ public function decode (array $ encodedEnvelope ): Envelope
33
+ {
34
+ return $ this ->serializer ->decode ($ encodedEnvelope );
35
+ }
36
+
37
+ public function encode (Envelope $ envelope ): array
38
+ {
39
+ return $ this ->serializer ->encode ($ envelope );
40
+ }
41
+ }
You can’t perform that action at this time.
0 commit comments