eZ\Publish\Core\FieldType\RichText\Normalizer::accept PHP Method

accept() abstract public method

Check if normalizer accepts given $input for normalization.
abstract public accept ( string $input ) : boolean
$input string
return boolean
    public abstract function accept($input);

Usage Example

Beispiel #1
0
 /**
  * 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;
 }