You are here

private function ArticleWrapper::__construct in Facebook Instant Articles 7.2

ArticleWrapper constructor.

Instantiates the InstantArticle object, adding Drupal Base module configs where appropriate. Also invokes a hook to allow other modules to alter the InstantArticle object before render or any other operation.

Note modules making use of this wrapper must set the required Canonical URL with:


InstantArticle->withCanonicalUrl($url);

Parameters

array $context: An associative array of contextual information altering the InstantArticle object.

int $language_direction: Language direction currently in use, one of LANGUAGE_LTR or LANGUAGE_RTL.

See also

hook_fb_instant_articles_article_alter()

File

src/ArticleWrapper.php, line 52
Contains \Drupal\fb_instant_articles\ArticleWrapper.

Class

ArticleWrapper
Wraps a FB Instant SDK article object with Drupal Base module configs and hooks for extensibility (without class inheritance, which the FB Instant SDK prevents by design).

Namespace

Drupal\fb_instant_articles

Code

private function __construct($context = array(), $language_direction = LANGUAGE_LTR) {
  $this->instantArticle = InstantArticle::create()
    ->addMetaProperty('op:generator:application', 'drupal/fb_instant_articles')
    ->addMetaProperty('op:generator:application:version', self::getApplicationVersion())
    ->withStyle(variable_get('fb_instant_articles_style', 'default'));
  if ($language_direction == LANGUAGE_RTL) {
    $this->instantArticle
      ->enableRTL();
  }
  drupal_alter('fb_instant_articles_article', $this->instantArticle, $context);
}