コード例 #1
0
 public function apply($transformer, $instant_article, $node)
 {
     // Builds the slideshow
     $slideshow = Slideshow::create();
     $instant_article->addChild($slideshow);
     $gallery = $this->getProperty(self::PROPERTY_JETPACK_DATA_GALLERY, $node);
     if ($gallery && isset($gallery)) {
         foreach ($gallery as $gallery_image) {
             // Constructs Image if it contains URL
             if (!Type::isTextEmpty($gallery_image['src'])) {
                 $image = Image::create();
                 $image->withURL($gallery_image['src']);
                 // Constructs Caption element when present in the JSON
                 if (!Type::isTextEmpty($gallery_image['caption'])) {
                     $caption = Caption::create();
                     $caption->appendText($gallery_image['caption']);
                     $image->withCaption($caption);
                 }
                 $slideshow->addImage($image);
             }
         }
     }
     $transformer->transform($slideshow, $node);
     return $instant_article;
 }
コード例 #2
0
 public function apply($transformer, $instant_article, $node)
 {
     // Builds the slideshow
     $slideshow = Slideshow::create();
     $instant_article->addChild($slideshow);
     $transformer->transform($slideshow, $node);
     return $instant_article;
 }
コード例 #3
0
 public function getContextClass()
 {
     return [Map::getClassName(), Image::getClassName(), Interactive::getClassName(), Slideshow::getClassName(), SocialEmbed::getClassName(), Video::getClassName()];
 }
コード例 #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;
 }
コード例 #5
0
 /**
  * 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 Slideshow::getClassName();
 }