public function apply($transformer, $audible, $node) { $audio = Audio::create(); // Builds the image $url = $this->getProperty(self::PROPERTY_AUDIO_URL, $node); $title = $this->getProperty(self::PROPERTY_AUDIO_TITLE, $node); $autoplay = $this->getProperty(self::PROPERTY_AUDIO_AUTOPLAY, $node); $muted = $this->getProperty(self::PROPERTY_AUDIO_MUTED, $node); if ($url) { $audio->withURL($url); $audible->withAudio($audio); } else { // URL is a required field for Audio $transformer->addWarning(new InvalidSelector(self::PROPERTY_AUDIO_URL, $audible, $node, $this)); } if ($title) { $audio->withTitle($title); } if ($autoplay === "" || $autoplay === "true" || $autoplay === "autoplay") { $audio->enableAutoplay(); } if ($muted === "" || $muted === "true" || $muted === "muted") { $audio->enableMuted(); } return $audible; }
/** * 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; }
/** * Adds audio to this image. * * @param Audio $audio The audio object * * @return $this */ public function withAudio($audio) { Type::enforce($audio, Audio::getClassName()); $this->audio = $audio; return $this; }