public function apply($transformer, $instant_article, $node)
 {
     $related_articles = RelatedArticles::create();
     // Builds the image
     $title = $this->getProperty(self::PROPERTY_TITLE, $node);
     if ($title) {
         $related_articles->withTitle($title);
         $instant_article->addChild($related_articles);
     }
     $transformer->transform($related_articles, $node);
     return $instant_article;
 }
Exemplo n.º 2
0
 /**
  * Sets the related articles within the footer of the article.
  *
  * @param RelatedArticles $related_articles - The related articles
  *
  * @return $this
  */
 public function withRelatedArticles($related_articles)
 {
     Type::enforce($related_articles, RelatedArticles::getClassName());
     $this->relatedArticles = $related_articles;
     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;
 }
 public function getContextClass()
 {
     return RelatedArticles::getClassName();
 }