You are here

function fb_instant_articles_display_node_load in Facebook Instant Articles 7

Implements hook_node_load().

File

modules/fb_instant_articles_display/fb_instant_articles_display.module, line 181
Hook implementations for Facebook Instant Articles Display module.

Code

function fb_instant_articles_display_node_load($nodes, $types) {
  if ($enabled_entity_types = fb_instant_articles_display_get_article_entity_types()) {
    $enabled_bundles = array_keys($enabled_entity_types['node']);
    if (!empty($enabled_bundles) && count(array_intersect($enabled_bundles, $types))) {
      foreach ($nodes as $node) {
        $layout_settings = fb_instant_articles_display_get_node_layout_settings($node->type);
        $wrapper = \Drupal\fb_instant_articles_display\DrupalInstantArticleDisplay::create($node, $layout_settings);

        // Store the InstantArticle wrapper object on the node entity to allow
        // field formatters and others to make changes/additions to it until it's
        // finally rendered out in hook_preprocess_node().
        $node->fb_instant_articles_display_wrapper = $wrapper;
      }
    }
  }
}