public function apply()

in src/Facebook/InstantArticles/Transformer/Rules/HeaderAdRule.php [50:80]


    public function apply($transformer, $header, $node)
    {
        $ad = Ad::create();

        // Builds the ad
        $height = $this->getProperty(self::PROPERTY_AD_HEIGHT_URL, $node);
        if ($height) {
            $ad->withHeight($height);
        }

        $width = $this->getProperty(self::PROPERTY_AD_WIDTH_URL, $node);
        if ($width) {
            $ad->withWidth($width);
        }

        $url = $this->getProperty(self::PROPERTY_AD_URL, $node);
        if ($url) {
            $ad->withSource($url);
        }

        $embed_code = $this->getProperty(self::PROPERTY_AD_EMBED_URL, $node);
        if ($embed_code) {
            $ad->withHTML(Transformer::cloneNode($embed_code));
        }

        if ($url || $embed_code) {
            $header->addAd($ad);
        }

        return $header;
    }