* @since 3.0
*/
interface IHtmlProcessor {
- /**
- * Processes the input html string.
- *
- * @param string $html html string
- * @param string $objectType object type identifier
- * @param integer $objectID object id
- */
- public function process($html, $objectType, $objectID = 0);
-
/**
* Returns the parsed html.
*
protected $htmlInputNodeProcessor;
/**
- * @inheritDoc
+ * Processes the input html string.
+ *
+ * @param string $html html string
+ * @param string $objectType object type identifier
+ * @param integer $objectID object id
*/
public function process($html, $objectType, $objectID = 0) {
- // object id is always `0` during input processing but is set
- // before saving embedded objects
- $this->setContext($objectType, 0);
+ $this->setContext($objectType, $objectID);
// enforce consistent newlines
$html = StringUtil::unifyNewlines($html);
protected $outputType = 'text/html';
/**
- * @inheritDoc
+ * Processes the input html string.
+ *
+ * @param string $html html string
+ * @param string $objectType object type identifier
+ * @param integer $objectID object id
*/
- public function process($html, $objectType, $objectID = 0) {
- if ($objectID === 0) {
- throw new \UnexpectedValueException('Object id cannot be 0 for output processing.');
- }
-
+ public function process($html, $objectType, $objectID) {
$this->setContext($objectType, $objectID);
$this->getHtmlOutputNodeProcessor()->setOutputType($this->outputType);
return $this->getHtmlOutputNodeProcessor()->getHtml();
}
+ /**
+ * @inheritdoc
+ * @throws \InvalidArgumentException
+ */
+ public function setContext($objectType, $objectID) {
+ if (!$objectID) {
+ throw new \InvalidArgumentException("Output processor requires a valid objectID.");
+ }
+
+ parent::setContext($objectType, $objectID);
+ }
+
/**
* Returns the output node processor instance.
*