예제 #1
0
 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;
 }
 public function getContextClass()
 {
     return [Map::getClassName(), Image::getClassName(), Interactive::getClassName(), Slideshow::getClassName(), SocialEmbed::getClassName(), Video::getClassName()];
 }
예제 #3
0
 public function testIsWithinFalseObj()
 {
     $image = Image::create();
     $video = Video::create();
     $anotherImg = Image::create();
     $result = Type::isWithin($image, [$anotherImg, $video, 'z']);
     $this->assertFalse($result);
 }
예제 #4
0
 /**
  * Sets the cover of InstantArticle with Image or Video
  *
  * @param Image|Video|Slideshow $cover The cover for the header of the InstantArticle
  *
  * @return $this
  */
 public function withCover($cover)
 {
     Type::enforce($cover, [Image::getClassName(), Slideshow::getClassName(), Video::getClassName()]);
     $this->cover = $cover;
     return $this;
 }
 /**
  * Adds new child elements to the front of this InstantArticle
  *
  * @param Element to be added to this Article.
  *
  * @return $this
  */
 public function unshiftChild($child)
 {
     Type::enforce($child, [Ad::getClassName(), Analytics::getClassName(), AnimatedGIF::getClassName(), Audio::getClassName(), Blockquote::getClassName(), Image::getClassName(), H1::getClassName(), H2::getClassName(), Interactive::getClassName(), ListElement::getClassName(), Map::getClassName(), Paragraph::getClassName(), Pullquote::getClassName(), RelatedArticles::getClassName(), Slideshow::getClassName(), SocialEmbed::getClassName(), Video::getClassName()]);
     array_unshift($this->children, $child);
     return $this;
 }
예제 #6
0
 public function getContextClass()
 {
     return [Image::getClassName(), Video::getClassName(), Map::getClassName()];
 }