eZ\Publish\Core\FieldType\RichText\ConverterDispatcher::dispatch PHP Method

dispatch() public method

Dispatches DOMDocument to the namespace mapped converter.
public dispatch ( DOMDocument $document ) : DOMDocument
$document DOMDocument
return DOMDocument
    public function dispatch(DOMDocument $document)
    {
        $documentNamespace = $document->documentElement->lookupNamespaceURI(null);
        // checking for null as ezxml has no default namespace...
        if ($documentNamespace === null) {
            $documentNamespace = $document->documentElement->lookupNamespaceURI('xhtml');
        }
        foreach ($this->mapping as $namespace => $converter) {
            if ($documentNamespace === $namespace) {
                if ($converter === null) {
                    return $document;
                }
                return $converter->convert($document);
            }
        }
        throw new NotFoundException('Converter', $documentNamespace);
    }

Usage Example

コード例 #1
0
ファイル: Type.php プロジェクト: ezsystems/ezpublish-kernel
 /**
  * Inspects given $inputValue and potentially converts it into a dedicated value object.
  *
  * @param \eZ\Publish\Core\FieldType\RichText\Value|\DOMDocument|string $inputValue
  *
  * @return \eZ\Publish\Core\FieldType\RichText\Value The potentially converted and structurally plausible value.
  */
 protected function createValueFromInput($inputValue)
 {
     if (is_string($inputValue)) {
         if (empty($inputValue)) {
             $inputValue = Value::EMPTY_VALUE;
         }
         if ($this->inputNormalizer !== null && $this->inputNormalizer->accept($inputValue)) {
             $inputValue = $this->inputNormalizer->normalize($inputValue);
         }
         $inputValue = $this->loadXMLString($inputValue);
     }
     if ($inputValue instanceof DOMDocument) {
         if ($this->inputValidatorDispatcher !== null) {
             $errors = $this->inputValidatorDispatcher->dispatch($inputValue);
             if (!empty($errors)) {
                 throw new InvalidArgumentException('$inputValue', 'Validation of XML content failed: ' . implode("\n", $errors));
             }
         }
         $inputValue = new Value($this->inputConverterDispatcher->dispatch($inputValue));
     }
     return $inputValue;
 }
All Usage Examples Of eZ\Publish\Core\FieldType\RichText\ConverterDispatcher::dispatch