public function apply()

in src/Facebook/InstantArticles/Transformer/Rules/VideoRule.php [100:157]


    public function apply($transformer, $instant_article, $node)
    {
        $video = Video::create();

        // Builds the image
        $url = $this->getProperty(self::PROPERTY_VIDEO_URL, $node);
        if ($url) {
            $video->withURL($url);
            $instant_article->addChild($video);
        } else {
            $transformer->addWarning(
                new InvalidSelector(
                    self::PROPERTY_VIDEO_URL,
                    $instant_article,
                    $node,
                    $this
                )
            );
        }

        $video_type = $this->getProperty(self::PROPERTY_VIDEO_TYPE, $node);
        if ($video_type) {
            $video->withContentType($video_type);
        }

        if ($this->getProperty(Video::ASPECT_FIT, $node)) {
            $video->withPresentation(Video::ASPECT_FIT);
        } elseif ($this->getProperty(Video::ASPECT_FIT_ONLY, $node)) {
            $video->withPresentation(Video::ASPECT_FIT_ONLY);
        } elseif ($this->getProperty(Video::FULLSCREEN, $node)) {
            $video->withPresentation(Video::FULLSCREEN);
        } elseif ($this->getProperty(Video::NON_INTERACTIVE, $node)) {
            $video->withPresentation(Video::NON_INTERACTIVE);
        }

        if ($this->getProperty(self::PROPERTY_CONTROLS, $node)) {
            $video->enableControls();
        }

        if ($this->getProperty(self::PROPERTY_PLAYBACK_MODE, $node)) {
            $video->disableAutoplay();
        }

        if ($this->getProperty(self::PROPERTY_LIKE, $node)) {
            $video->enableLike();
        }

        if ($this->getProperty(self::PROPERTY_COMMENTS, $node)) {
            $video->enableComments();
        }

        $suppress_warnings = $transformer->suppress_warnings;
        $transformer->suppress_warnings = true;
        $transformer->transform($video, $node);
        $transformer->suppress_warnings = $suppress_warnings;

        return $instant_article;
    }