| 1 |
<?php |
| 2 |
|
| 3 |
namespace Wikimedia\RemexHtml\TreeBuilder; |
| 4 |
|
| 5 |
use Wikimedia\RemexHtml\Tokenizer\Attributes; |
| 6 |
|
| 7 |
/** |
| 8 |
* A TreeHandler which simply passes all events through to another handler. |
| 9 |
* |
| 10 |
* Applications can subclass this in order to modify only a few event types |
| 11 |
* as they pass through. |
| 12 |
* |
| 13 |
* @since 2.1.0 |
| 14 |
*/ |
| 15 |
class RelayTreeHandler implements TreeHandler { |
| 16 |
protected TreeHandler $nextHandler; |
| 17 |
|
| 18 |
/** |
| 19 |
* Construct a RelayTreeHandler which will call $nextHandler on all events |
| 20 |
*/ |
| 21 |
public function __construct( TreeHandler $nextHandler ) { |
| 22 |
$this->nextHandler = $nextHandler; |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* @inheritDoc |
| 27 |
*/ |
| 28 |
public function startDocument( $fragmentNamespace, $fragmentName ) { |
| 29 |
$this->nextHandler->startDocument( $fragmentNamespace, $fragmentName ); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* @inheritDoc |
| 34 |
*/ |
| 35 |
public function endDocument( $pos ) { |
| 36 |
$this->nextHandler->endDocument( $pos ); |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* @inheritDoc |
| 41 |
*/ |
| 42 |
public function characters( |
| 43 |
$preposition, $ref, $text, $start, $length, $sourceStart, $sourceLength |
| 44 |
) { |
| 45 |
$this->nextHandler->characters( $preposition, $ref, $text, $start, $length, |
| 46 |
$sourceStart, $sourceLength ); |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* @inheritDoc |
| 51 |
*/ |
| 52 |
public function insertElement( $preposition, $ref, Element $element, $void, |
| 53 |
$sourceStart, $sourceLength |
| 54 |
) { |
| 55 |
$this->nextHandler->insertElement( $preposition, $ref, $element, $void, |
| 56 |
$sourceStart, $sourceLength ); |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* @inheritDoc |
| 61 |
*/ |
| 62 |
public function endTag( Element $element, $sourceStart, $sourceLength ) { |
| 63 |
$this->nextHandler->endTag( $element, $sourceStart, $sourceLength ); |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* @inheritDoc |
| 68 |
*/ |
| 69 |
public function doctype( $name, $public, $system, $quirks, $sourceStart, $sourceLength ) { |
| 70 |
$this->nextHandler->doctype( $name, $public, $system, $quirks, |
| 71 |
$sourceStart, $sourceLength ); |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* @inheritDoc |
| 76 |
*/ |
| 77 |
public function comment( $preposition, $ref, $text, $sourceStart, $sourceLength ) { |
| 78 |
$this->nextHandler->comment( $preposition, $ref, $text, $sourceStart, $sourceLength ); |
| 79 |
} |
| 80 |
|
| 81 |
/** |
| 82 |
* @inheritDoc |
| 83 |
*/ |
| 84 |
public function error( $text, $pos ) { |
| 85 |
$this->nextHandler->error( $text, $pos ); |
| 86 |
} |
| 87 |
|
| 88 |
/** |
| 89 |
* @inheritDoc |
| 90 |
*/ |
| 91 |
public function mergeAttributes( Element $element, Attributes $attrs, $sourceStart ) { |
| 92 |
$this->nextHandler->mergeAttributes( $element, $attrs, $sourceStart ); |
| 93 |
} |
| 94 |
|
| 95 |
/** |
| 96 |
* @inheritDoc |
| 97 |
*/ |
| 98 |
public function removeNode( Element $element, $sourceStart ) { |
| 99 |
$this->nextHandler->removeNode( $element, $sourceStart ); |
| 100 |
} |
| 101 |
|
| 102 |
/** |
| 103 |
* @inheritDoc |
| 104 |
*/ |
| 105 |
public function reparentChildren( Element $element, Element $newParent, $sourceStart ) { |
| 106 |
$this->nextHandler->reparentChildren( $element, $newParent, $sourceStart ); |
| 107 |
} |
| 108 |
} |