Step 1 of The push towards JSON-LD support in Drupal
suggests to implement JSON serialization without JSON-LD support. Serializer was mentioned as a Symfony2 component that handles this. I looked into this a little back in August and it looks like we would need to have an EntityNormalizer and EntitySerializer (and possibly abstracted even further with DrupalNormalizer and DrupalSerializer).

Here's a patch with the current Serializer 2.1 branch that places the library within the path core/vendor/symfony/serializer. It hacks composer into loading Serializer for now as that was the quickest way I could get it to load.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mradcliffe’s picture

Okay, this should probably work, but I don't think any entity implements getPropertyValues yet. I did a small test by hacking in getPropertyValues into Node.php.

Also adding a dependency onto the Entity class is probably wrong, but I'm not sure where else to put it - EntityWrapper? Or maybe it should go in TypedData and separate from entities?

Edit: whoops, patch has some evidence of me murdering kittens in it. :-)

Anonymous’s picture

Sorry, I hadn't been watching the queue since I hadn't posted code yet, so I didn't see this issue.

I agree with the idea. I've got a good start on something using the Serializer component and custom Normalizer/Encoders. I'll be posting that as a patch soon, most likely to an issue on core queue.

I will also be posting a separate issue to include the Serializer component in core. Would you mind cleaning up your patch, removing anything that isn't directly related to adding the Symfony component? We can use this issue to work on that for now. I've posted an issue to core, you can post the patch there #1810472: Add Symfony's Serializer component to core despite Symfony potentially releasing BC-breaking updates after 2.3.. Thanks!

mradcliffe’s picture

Status: Active » Closed (duplicate)

Closing this issue.