You are here

private function DrupalInstantArticleDisplay::fieldFormatInteractiveElement in Facebook Instant Articles 7

Formatter for the Interactive element.

Parameters

$items:

InstantArticle $body:

$settings:

1 call to DrupalInstantArticleDisplay::fieldFormatInteractiveElement()
DrupalInstantArticleDisplay::fieldFormatterView in modules/fb_instant_articles_display/src/DrupalInstantArticleDisplay.php

File

modules/fb_instant_articles_display/src/DrupalInstantArticleDisplay.php, line 507
Contains \Drupal\fb_instant_articles_display\DrupalInstantArticleDisplay.

Class

DrupalInstantArticleDisplay
Facebook Instant Article node wrapper class. Builds up an InstantArticle object using field formatters.

Namespace

Drupal\fb_instant_articles_display

Code

private function fieldFormatInteractiveElement($items, $body, $settings) {
  foreach ($items as $delta => $item) {
    $interactive = Interactive::create();
    if (!empty($settings['height'])) {
      $interactive
        ->withHeight($settings['height']);
    }
    if (!empty($settings['width'])) {
      $interactive
        ->withWidth($settings['width']);
    }

    // @todo sanitize text before sending off to FB IA SDK?
    $interactive
      ->withHTML($item['value']);
    $body
      ->addChild($interactive);
  }
}