in src/Facebook/InstantArticles/Transformer/Rules/InstantArticleRule.php [53:106]
public function apply($transformer, $instant_article, $node)
{
// Builds the image
$url = $this->getProperty(self::PROPERTY_CANONICAL, $node);
if ($url) {
$instant_article->withCanonicalURL($url);
} else {
$transformer->addWarning(
new InvalidSelector(
self::PROPERTY_CANONICAL,
$instant_article,
$node,
$this
)
);
}
$charset = $this->getProperty(self::PROPERTY_CHARSET, $node);
if ($charset) {
$instant_article->withCharset($charset);
}
$markup_version = $this->getProperty(self::PROPERTY_MARKUP_VERSION, $node);
if ($markup_version) {
//TODO Validate if the markup is valid with this code
}
$auto_ad_placement = $this->getProperty(self::PROPERTY_AUTO_AD_PLACEMENT, $node);
if ($auto_ad_placement === 'false') {
$instant_article->disableAutomaticAdPlacement();
} else {
$instant_article->enableAutomaticAdPlacement();
$pairs = explode(' ', $auto_ad_placement, 2);
if (count($pairs) === 2) {
list($name, $value) = explode('=', $pairs[1], 2);
$instant_article->withAdDensity($value);
}
}
$recirculation_ad_placement = $this->getProperty(self::PROPERTY_RECIRCULATION_AD_PLACEMENT, $node);
if (is_null($recirculation_ad_placement)) {
$instant_article->disableAutomaticRecirculationPlacement();
} else {
$instant_article->enableAutomaticRecirculationPlacement();
$instant_article->withRecirculationPlacement($recirculation_ad_placement);
}
$style = $this->getProperty(self::PROPERTY_STYLE, $node);
if ($style) {
$instant_article->withStyle($style);
}
return $instant_article;
}