eZ\Publish\Core\FieldType\RichText\Converter\Render\Embed::processTag PHP Method

processTag() protected method

Processes single embed element type (ezembed or ezembedinline).
protected processTag ( DOMDocument $document, $tagName, boolean $isInline )
$document DOMDocument
$tagName string name of the tag to extract
$isInline boolean
    protected function processTag(DOMDocument $document, $tagName, $isInline)
    {
        /** @var $embed \DOMElement */
        foreach ($document->getElementsByTagName($tagName) as $embed) {
            $embedContent = null;
            $parameters = $this->extractParameters($embed, $tagName);
            $resourceReference = $embed->getAttribute('xlink:href');
            if (empty($resourceReference)) {
                if (isset($this->logger)) {
                    $this->logger->error("Could not embed resource: empty 'xlink:href' attribute");
                }
            } elseif (0 === preg_match('~^(ezcontent|ezlocation)://(.*)$~', $resourceReference, $matches)) {
                if (isset($this->logger)) {
                    $this->logger->error("Could not embed resource: unhandled resource reference '{$resourceReference}'");
                }
            } elseif ($matches[1] === 'ezcontent') {
                $parameters['id'] = $matches[2];
                $embedContent = $this->renderer->renderContentEmbed($parameters['id'], $parameters['viewType'], array('embedParams' => $parameters), $isInline);
            } elseif ($matches[1] === 'ezlocation') {
                $parameters['id'] = $matches[2];
                $embedContent = $this->renderer->renderLocationEmbed($parameters['id'], $parameters['viewType'], array('embedParams' => $parameters), $isInline);
            }
            if (isset($embedContent)) {
                $payload = $document->createElement('ezpayload');
                $payload->appendChild($document->createCDATASection($embedContent));
                $embed->appendChild($payload);
            }
        }
    }