| 1 |
<?php |
| 2 |
|
| 3 |
namespace Wikimedia\RemexHtml\Tokenizer; |
| 4 |
|
| 5 |
/** |
| 6 |
* A TokenHandler which simply passes all tokens through to another token |
| 7 |
* handler, specified in the constructor. |
| 8 |
* |
| 9 |
* Applications can subclass this in order to modify only a few token types |
| 10 |
* as they pass through. |
| 11 |
* |
| 12 |
* @since 2.1.0 |
| 13 |
*/ |
| 14 |
class RelayTokenHandler implements TokenHandler { |
| 15 |
protected TokenHandler $nextHandler; |
| 16 |
|
| 17 |
/** |
| 18 |
* Construct a RelayTokenHandler which will call $nextHandler on all events |
| 19 |
* |
| 20 |
* @param TokenHandler $nextHandler |
| 21 |
*/ |
| 22 |
public function __construct( TokenHandler $nextHandler ) { |
| 23 |
$this->nextHandler = $nextHandler; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* @inheritDoc |
| 28 |
*/ |
| 29 |
public function startDocument( Tokenizer $tokenizer, $fragmentNamespace, $fragmentName ) { |
| 30 |
$this->nextHandler->startDocument( $tokenizer, $fragmentNamespace, $fragmentName ); |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* @inheritDoc |
| 35 |
*/ |
| 36 |
public function endDocument( $pos ) { |
| 37 |
$this->nextHandler->endDocument( $pos ); |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* @inheritDoc |
| 42 |
*/ |
| 43 |
public function error( $text, $pos ) { |
| 44 |
$this->nextHandler->error( $text, $pos ); |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* @inheritDoc |
| 49 |
*/ |
| 50 |
public function characters( $text, $start, $length, $sourceStart, $sourceLength ) { |
| 51 |
$this->nextHandler->characters( $text, $start, $length, $sourceStart, $sourceLength ); |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* @inheritDoc |
| 56 |
*/ |
| 57 |
public function startTag( $name, Attributes $attrs, $selfClose, $sourceStart, $sourceLength ) { |
| 58 |
$this->nextHandler->startTag( $name, $attrs, $selfClose, $sourceLength, $sourceLength ); |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* @inheritDoc |
| 63 |
*/ |
| 64 |
public function endTag( $name, $sourceStart, $sourceLength ) { |
| 65 |
$this->nextHandler->endTag( $name, $sourceStart, $sourceLength ); |
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* @inheritDoc |
| 70 |
*/ |
| 71 |
public function doctype( $name, $public, $system, $quirks, $sourceStart, $sourceLength ) { |
| 72 |
$this->nextHandler->doctype( $name, $public, $system, $quirks, $sourceStart, |
| 73 |
$sourceLength ); |
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* @inheritDoc |
| 78 |
*/ |
| 79 |
public function comment( $text, $sourceStart, $sourceLength ) { |
| 80 |
$this->nextHandler->comment( $text, $sourceStart, $sourceLength ); |
| 81 |
} |
| 82 |
} |