Slide 1

Slide 1 text

Serializer Demystified

Slide 2

Slide 2 text

SensioLabs Deutschland [email protected] @dbrumann

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

interface EncoderInterface { public function encode($data, string $format, array $context = []); public function supportsEncoding(string $format); } interface NormalizerInterface { public function normalize($object, string $format = null, array $context = []); public function supportsNormalization($data, string $format = null); }

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

interface DenormalizerInterface { public function denormalize($data, string $type, string $format = null, array $context = []); public function supportsDenormalization($data, string $type, string $format = null); } interface DecoderInterface { public function decode(string $data, string $format, array $context = []); public function supportsDecoding(string $format); }

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

Key Default Value Comment JsonEncode::OPTIONS 0 json_encode()-options bitmask JsonDecode::OPTIONS 0 json_decode()-options bitmask JsonDecode::ASSOCIATIVE false Whether json_decode() should return associative array or stdClass JsonDecode::RECURSION_DEPTH 512 Recursion depth for json_decode()

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

GetSetMethodNormalizer get…, is…, has… set… PropertyNormalizer Reflection for accessing class attributes ObjectNormalizer Uses Symfony PropertyAccess get…, is…, has… public properties add…/remove… for single entry in collections

Slide 34

Slide 34 text

Symfony\Component\Serializer\Normalizer\ CacheableSupportsMethodInterface interface CacheableSupportsMethodInterface { public function hasCacheableSupportsMethod(): bool; }

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

AbstractNormalizer:: Keys Description ALLOW_EXTRA_ATTRIBUTES On denormalization extra attributes, that do not match the object, are ignored instead of throwing an error ATTRIBUTES Array of class properties that should be encoded/decoded, including nested properties, e.g.: ['familyName', 'company' => ['name']] IGNORED_ATTRIBUTES List of attributes to be ignored on encoding/decoding GROUPS Serialization groups to consider for encoding/decoding (can be specified with annotation on class properties)

Slide 48

Slide 48 text

No content