Problem/Motivation

In order to support the API approach of submitting entities to Facebook as instant articles, out of the box, we need a way for entities (at least nodes) to be converted and sent via the API on node save. Similarly we also need to have the articles deleted when the entity is deleted if it exists as an instant article.

Proposed resolution

Implement hook_entity_save and hook_entity_delete, with alter hooks to import and delete the article respectively.

Remaining tasks

Implementation

User interface changes

None.

API changes

None.

Data model changes

None.

Comments

m4olivei created an issue. See original summary.

m4olivei’s picture

Issue summary: View changes
m4olivei’s picture

Assigned: Unassigned » m4olivei
m4olivei’s picture

Hum core triggers are dead in D8 (https://www.drupal.org/node/764558), and one of my goals was to not ship the module with a requirement on rules to make use of the API approach. Rules is heavy and by default the D7 module didn't use it for much more than to ship a default rule configuration.

We could still ship a usable action that would let someone use Rules module themselves, but I'd rather see an out of the box solution, like simply implementing hook_entity_save with an alter to allow developers to insert their own business logic around which nodes go to instant articles.

This got me thinking that it might also fit to move to a model of the base model having everything necessary to programatically support the RSS and API approach, and then having super light sub-modules for views and api. The _views sub-module would just be the filter and default view config. The api would just be a hook_entity_save, hook_entity_delete, and alter hook to insert business logic. Leaving it super easy for developers to just turn on the base module and go with their own solution if they want (eg. importing via drush or using a queue), or turn on a default super simple and lightweight out of the box integration for either RSS or API.

m4olivei’s picture

Title: Core actions support for import and delete API operations » hook_entity_save support for import and delete API operations
Issue summary: View changes
Issue tags: -fb_instant_articles_rules +fb_instant_articles_api

Updated title and description. Moving to use hook_entity_(save|delete) to do FB API actions in the _api sub-module. If there is interest in rules support, we can implement an action in the base module or a separate _actions submodule. I'd review patches for that, but I don't have any requests from a client for that admin flexibility at this point.

m4olivei’s picture

m4olivei’s picture

Status: Active » Needs review

Tests added, ready for review.

  • m4olivei committed 0da0154 on 2871646-hook-entity-save
    Issue #2871646 add logging for importing and removing articles from...
  • m4olivei committed 103c54e on 2871646-hook-entity-save
    Issue #2871646 added tests for DrupalClient.
    
  • m4olivei committed 1447ce1 on 2871646-hook-entity-save
    Issue #2871646 fix sorting issue with components in different regions.
    
  • m4olivei committed 1915ae5 on 2871646-hook-entity-save
    Issue #2871646 update the RSS encoder to take the canonical URL override...
  • m4olivei committed 399608d on 2871646-hook-entity-save
    Issue #2871646 comment fix.
    
  • m4olivei committed 523e235 on 2871646-hook-entity-save
    Issue #2871646 First pass at implementing the API approch on...
  • m4olivei committed 5abf2d2 on 2871646-hook-entity-save
    Issue #2871646 need serialization module in the modules list for tests.
    
  • m4olivei committed 654fec7 on 2871646-hook-entity-save
    Issue #2871646 Fix a couple minor issues with fb client factory class...
  • m4olivei committed dd1799b on 2871646-hook-entity-save
    Issue #2871646 throw an exception when API credentials are not...

  • m4olivei committed 0da0154 on 8.x-2.x
    Issue #2871646 add logging for importing and removing articles from...
  • m4olivei committed 103c54e on 8.x-2.x
    Issue #2871646 added tests for DrupalClient.
    
  • m4olivei committed 1447ce1 on 8.x-2.x
    Issue #2871646 fix sorting issue with components in different regions.
    
  • m4olivei committed 1915ae5 on 8.x-2.x
    Issue #2871646 update the RSS encoder to take the canonical URL override...
  • m4olivei committed 316b8b2 on 8.x-2.x
    Issue #2871646 fix a typo.
    
  • m4olivei committed 399608d on 8.x-2.x
    Issue #2871646 comment fix.
    
  • m4olivei committed 4519aac on 8.x-2.x
    Issue #2871646 docblock comment updates and fix a typo.
    
  • m4olivei committed 523e235 on 8.x-2.x
    Issue #2871646 First pass at implementing the API approch on...
  • m4olivei committed 5abf2d2 on 8.x-2.x
    Issue #2871646 need serialization module in the modules list for tests.
    
  • m4olivei committed 654fec7 on 8.x-2.x
    Issue #2871646 Fix a couple minor issues with fb client factory class...
  • m4olivei authored a2d1e12 on 8.x-2.x
    Issue #2871646 by m4olivei, sunset_bill: hook_entity_save support for...
  • m4olivei committed dd1799b on 8.x-2.x
    Issue #2871646 throw an exception when API credentials are not...
m4olivei’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed and approved by @sunset_bill.

m4olivei’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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