Problem/Motivation
We need a way to convert entities, primarily nodes, into Facebook Instant Article document format so that they can be aggregated in an RSS feed, or sent in an API request to Facebook for submission into the Facebook Instant Article platform.
Proposed resolution
Make use of Drupal's Serialization API to facilitate the conversion. This will make the process straightforward, testable and using standard approach. Consistency++.
Remaining tasks
1. Implement normalizer
Implement a normalizer to normalize content entities into InstantArticle objects. InstantArticle objects are implemented in the Facebook PHP SDK, which is required by this module. See the following test on the FBIA PHP SDK for details on how that InstantArticle is used:
https://github.com/facebook/facebook-instant-articles-sdk-php/blob/maste...
See also the Drupal 7 version of the module. The normalizer would return an InstantArticle object. We should implement mutliple normalizers as required to accomplish the normalization recursively. See https://www.lullabot.com/articles/drupal-serialization-step-by-step for an excellent example of how that works.
2. Implement encoder
The encoder is responsible for taking an InstantArticle object and generating the FBIA document markup. The encoder we need should be fairly simple, it just needs to call InstantArticle::render().
User interface changes
None.
API changes
Add an API to serialize content entities into FBIA documents, such that you can do something like:
\Drupal::service('serializer')->serialize(\Drupal\node\Entity\Node::load(1), 'fbia')Data model changes
None.
Comments
Comment #2
m4oliveiAs per #2871637: Research alternative architectural approach for converting content entities to Facebook Instant Articles, we're going to make use of the Serialization API to manage the conversion to FBIA formatted documents. Updating title and description accordingly.
Comment #3
m4oliveiNote that as per #2871637: Research alternative architectural approach for converting content entities to Facebook Instant Articles, fb_instant_articles_display is going away as a sub-module, so this functionality should be added to the base module, fb_instant_articles.
Comment #4
m4oliveiComment #5
m4oliveiReady for review, see PR for more details: https://github.com/BurdaMagazinOrg/module-fb_instant_articles/pull/98
Comment #7
m4oliveiReviewed and merged, see PR for details.