deserialization process which you can use to hook in and alter the default behavior.” • serializer.pre_serialize • serializer.post_serialize • serializer.pre_deserialize • serializer.post_deserialize 26
public function getUserAction(User $user) { $package = $this->get('templating.helper.assets')->getPackage(); $user->setAvatarUrl($package->getUrl($user->getImagePath())); $this->get('serializer')->serialize($user, 'json'); // ... } What you could do ... 28
public function getUserAction(User $user) { $package = $this->get('templating.helper.assets')->getPackage(); $user->setAvatarUrl($package->getUrl($user->getImagePath())); $this->get('serializer')->serialize($user, 'json'); // ... } public function getUserListAction() { foreach () { // ... well ... doable } } What you could do ... 28
public function getUserAction(User $user) { $package = $this->get('templating.helper.assets')->getPackage(); $user->setAvatarUrl($package->getUrl($user->getImagePath())); $this->get('serializer')->serialize($user, 'json'); // ... } public function getUserListAction() { foreach () { // ... well ... doable } } public function getPostsWithAuthorsAction() { // Whhaaattttt } What you could do ... 28
embed data from services (forms, pagerfanta, etc) • Handler for Pagerfanta • Handler for Form instances https://github.com/TheFootballSocialClub/FSCHateoasBundle A bundle I’ve created using many of the serializer features. Have a look at the code to learn more :) 34