/** * Load assets from the custom elements (CustomInteraction, PCI, PIC) * @param Element $element the custom element */ private function loadCustomElementAssets(Element $element) { if ($this->getGetCustomElementDefinition()) { if ($element instanceof PortableCustomInteraction) { $this->assets['PCI'][$element->getTypeIdentifier()] = $element; } if ($element instanceof PortableInfoControl) { $this->assets['PIC'][$element->getTypeIdentifier()] = $element; } } $xmls = array(); if ($element instanceof PortableCustomInteraction || $element instanceof PortableInfoControl) { //some portable elements contains htmlentitied markup in their properties... $xmls = $this->getXmlProperties($element->getProperties()); } //parse and extract assets from markup using XPATH if ($element instanceof CustomInteraction || $element instanceof InfoControl) { // http://php.net/manual/fr/simplexmlelement.xpath.php#116622 $sanitizedMarkup = str_replace('xmlns=', 'ns=', $element->getMarkup()); $xmls[] = new SimpleXMLElement($sanitizedMarkup); $this->loadCustomElementPropertiesAssets($element->getProperties()); /** @var SimpleXMLElement $xml */ foreach ($xmls as $xml) { foreach ($xml->xpath('//img') as $img) { $this->addAsset('img', (string) $img['src']); } foreach ($xml->xpath('//video') as $video) { $this->addAsset('video', (string) $video['src']); } foreach ($xml->xpath('//audio') as $audio) { $this->addAsset('audio', (string) $audio['src']); } } } }