public function apply($transformer, $context_element, $node) { $h1 = H1::create(); if (Type::is($context_element, array(Header::getClassName(), Caption::getClassName()))) { $context_element->withTitle($h1); } elseif (Type::is($context_element, InstantArticle::getClassName())) { $context_element->addChild($h1); } if ($this->getProperty(Caption::POSITION_BELOW, $node)) { $h1->withPosition(Caption::POSITION_BELOW); } if ($this->getProperty(Caption::POSITION_CENTER, $node)) { $h1->withPosition(Caption::POSITION_CENTER); } if ($this->getProperty(Caption::POSITION_ABOVE, $node)) { $h1->withPosition(Caption::POSITION_ABOVE); } if ($this->getProperty(Caption::ALIGN_LEFT, $node)) { $h1->withTextAlignment(Caption::ALIGN_LEFT); } if ($this->getProperty(Caption::ALIGN_CENTER, $node)) { $h1->withTextAlignment(Caption::ALIGN_CENTER); } if ($this->getProperty(Caption::ALIGN_RIGHT, $node)) { $h1->withTextAlignment(Caption::ALIGN_RIGHT); } $transformer->transform($h1, $node); return $context_element; }
public function apply($transformer, $header, $h1) { $header->withTitle($transformer->transform(H1::create(), $h1)); return $header; }
/** * The caption title. REQUIRED. * * @param H1|string $title the caption text that will be shown * * @return $this */ public function withTitle($title) { Type::enforce($title, [Type::STRING, H1::getClassName()]); if (Type::is($title, Type::STRING)) { $title = H1::create()->appendText($title); } $this->title = $title; 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; }