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

m4olivei created an issue. See original summary.

m4olivei’s picture

Title: Manage creation and rendering of InstantArticle object via the node API » Manage creation and rendering of InstantArticle object via the Serialization API
Issue summary: View changes

As 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.

m4olivei’s picture

Note 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.

m4olivei’s picture

Assigned: Unassigned » m4olivei
m4olivei’s picture

Assigned: m4olivei » Unassigned
Status: Active » Needs review

  • m4olivei committed 04d9f16 on 8.x-2.x
    Issue #2872807 trim the list of supported field types for...
  • m4olivei committed 0850b87 on 8.x-2.x
    Issue #2872807 Complete the ListFormatter implementation for instant...
  • m4olivei committed 10217ce on 8.x-2.x
    Issue #2872807 tests for transformerformatter.
    
  • m4olivei committed 154e899 on 8.x-2.x
    Issue #2872807 remove social formatter, it's been deprecated upstream
    
  • m4olivei committed 1bcc506 on 8.x-2.x
    Issue #2872807 Fill out the Blockquote field formatter implementation...
  • m4olivei committed 212e86c on 8.x-2.x
    Issue #2872807 Fix issues with the base settings form.
    
  • m4olivei committed 25a6b3a on 8.x-2.x
    Issue #2872807 write tests for ImageFormatter and VideoFormatter.
    
  • m4olivei committed 326831e on 8.x-2.x
    Issue #2872807 Round out the architecture we'll use to tie serialization...
  • m4olivei committed 3967d3d on 8.x-2.x
    Issue #2872807 add some assertions to the ListFormatterTest for the...
  • m4olivei committed 3a2928e on 8.x-2.x
    Issue #2872807 Implement instant article image formatter details
    
  • m4olivei committed 434ae13 on 8.x-2.x
    Issue #2872807 Tidy up the Transformer wrapper implemetation to make it...
  • m4olivei committed 5937b2a on 8.x-2.x
    Issue #2872807 add serialization module as a dependency of...
  • m4olivei authored 6c2b156 on 8.x-2.x
    Issue #2872807 by m4olivei: Manage creation and rendering of...
  • m4olivei committed 7455651 on 8.x-2.x
    Issue #2872807 Document the...
  • m4olivei committed 79e5e68 on 8.x-2.x
    Issue #2872807 writing tests against the ContentEntityNormalizer
    
  • m4olivei committed 8a2996d on 8.x-2.x
    Issue #2872807 Add the first couple of field formatter tests.
    
  • m4olivei committed 8ec26b2 on 8.x-2.x
    Issue #2872807 Add a couple simple tests to begin with.
    
  • m4olivei committed 9001221 on 8.x-2.x
    Issue #2872807 More complete Ad formatter implementation
    
  • m4olivei committed 9602f9c on 8.x-2.x
    Issue #2872807 documentation and defaults update
    
  • m4olivei committed aa7df7b on 8.x-2.x
    Issue #2872807 Test instant article ad formatter.
    
  • m4olivei committed ab6d561 on 8.x-2.x
    Issue #2872807 Include tests for global ad settings, shifting the global...
  • m4olivei committed ac214dc on 8.x-2.x
    Issue #2872807 Complete the credits formatter instant articles...
  • m4olivei committed ac8525a on 8.x-2.x
    Issue #2872807 Fill out AnalyticsFormatter implementation to handle...
  • m4olivei committed ad139a6 on 8.x-2.x
    Issue #2872807 split up ContentEntityNormalizer into some helper methods...
  • m4olivei committed b7d3fd2 on 8.x-2.x
    Issue #2872807 Add normalize code creating the InstantArticle object and...
  • m4olivei committed bc8aaf8 on 8.x-2.x
    Issue #2872807 Fill out the instant article author formatter
    
  • m4olivei committed bff0f69 on 8.x-2.x
    Issue #2872807 Skeleton resources for doing FBIA serialization
    
  • m4olivei committed c21ef1a on 8.x-2.x
    Issue #2872807 Make some organizational changes to the Content Entity...
  • m4olivei committed c406896 on 8.x-2.x
    Issue #2872807 add tests for AnalyticsFormatter, AuthorFormatter, and...
  • m4olivei committed c771661 on 8.x-2.x
    Issue #2872807 Add tests for CopyrightFormatter, CreditsFormatter, and...
  • m4olivei committed c8a0ea6 on 8.x-2.x
    Issue #2872807 test coverage for BlockquoteFormatter, ParagraphFormatter...
  • m4olivei committed c8fc336 on 8.x-2.x
    Issue #2872807 Fix a couple minor code style things
    
  • m4olivei committed cb4740f on 8.x-2.x
    Issue #2872807 Finish KickerFormatter implementation with support for...
  • m4olivei committed cb6b859 on 8.x-2.x
    Issue #2872807 Finish the video formatter implementation
    
  • m4olivei committed dc532d2 on 8.x-2.x
    Issue #2872807 Fill out the implementation for the CopyrightFormatter
    
  • m4olivei committed dd21bd0 on 8.x-2.x
    Issue #2872807 fix an issue with ImageFormatter inheriting from cores...
  • m4olivei committed dd9c764 on 8.x-2.x
    Issue #2872807 write tests for kickerformatter and subtitleformatter.
    
  • m4olivei committed e3feeaf on 8.x-2.x
    Issue #2872807 Finish first pass at Content Entity Normalizer
    
  • m4olivei committed f160978 on 8.x-2.x
    Issue #2872807 Add config schema for all of the added field formatters
    
  • m4olivei committed f5c26a3 on 8.x-2.x
    Issue #2872807 Implement the field formatter associated with the...
  • m4olivei committed fc8ef75 on 8.x-2.x
    Issue #2872807 Adapt AdFormatter to work with the Serialization API
    
m4olivei’s picture

Status: Needs review » Fixed

Reviewed and merged, see PR for details.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.