| 1 |
<?php |
| 2 |
/** |
| 3 |
* @file |
| 4 |
* The interface definition for Rules to generate output. |
| 5 |
*/ |
| 6 |
|
| 7 |
namespace Masterminds\HTML5\Serializer; |
| 8 |
|
| 9 |
/** |
| 10 |
* To create a new rule set for writing output the RulesInterface needs to be implemented. |
| 11 |
* The resulting class can be specified in the options with the key of rules. |
| 12 |
* |
| 13 |
* For an example implementation see Serializer\OutputRules. |
| 14 |
*/ |
| 15 |
interface RulesInterface |
| 16 |
{ |
| 17 |
/** |
| 18 |
* The class constructor. |
| 19 |
* |
| 20 |
* Note, before the rules can be used a traverser must be registered. |
| 21 |
* |
| 22 |
* @param mixed $output The output stream to write output to. |
| 23 |
* @param array $options An array of options. |
| 24 |
*/ |
| 25 |
public function __construct($output, $options = array()); |
| 26 |
|
| 27 |
/** |
| 28 |
* Register the traverser used in but the rules. |
| 29 |
* |
| 30 |
* Note, only one traverser can be used by the rules. |
| 31 |
* |
| 32 |
* @param Traverser $traverser The traverser used in the rules. |
| 33 |
* |
| 34 |
* @return RulesInterface $this for the current object. |
| 35 |
*/ |
| 36 |
public function setTraverser(Traverser $traverser); |
| 37 |
|
| 38 |
/** |
| 39 |
* Write a document element (\DOMDocument). |
| 40 |
* |
| 41 |
* Instead of returning the result write it to the output stream ($output) |
| 42 |
* that was passed into the constructor. |
| 43 |
* |
| 44 |
* @param \DOMDocument $dom |
| 45 |
*/ |
| 46 |
public function document($dom); |
| 47 |
|
| 48 |
/** |
| 49 |
* Write an element. |
| 50 |
* |
| 51 |
* Instead of returning the result write it to the output stream ($output) |
| 52 |
* that was passed into the constructor. |
| 53 |
* |
| 54 |
* @param mixed $ele |
| 55 |
*/ |
| 56 |
public function element($ele); |
| 57 |
|
| 58 |
/** |
| 59 |
* Write a text node. |
| 60 |
* |
| 61 |
* Instead of returning the result write it to the output stream ($output) |
| 62 |
* that was passed into the constructor. |
| 63 |
* |
| 64 |
* @param mixed $ele |
| 65 |
*/ |
| 66 |
public function text($ele); |
| 67 |
|
| 68 |
/** |
| 69 |
* Write a CDATA node. |
| 70 |
* |
| 71 |
* Instead of returning the result write it to the output stream ($output) |
| 72 |
* that was passed into the constructor. |
| 73 |
* |
| 74 |
* @param mixed $ele |
| 75 |
*/ |
| 76 |
public function cdata($ele); |
| 77 |
|
| 78 |
/** |
| 79 |
* Write a comment node. |
| 80 |
* |
| 81 |
* Instead of returning the result write it to the output stream ($output) |
| 82 |
* that was passed into the constructor. |
| 83 |
* |
| 84 |
* @param mixed $ele |
| 85 |
*/ |
| 86 |
public function comment($ele); |
| 87 |
|
| 88 |
/** |
| 89 |
* Write a processor instruction. |
| 90 |
* |
| 91 |
* To learn about processor instructions see InstructionProcessor |
| 92 |
* |
| 93 |
* Instead of returning the result write it to the output stream ($output) |
| 94 |
* that was passed into the constructor. |
| 95 |
* |
| 96 |
* @param mixed $ele |
| 97 |
*/ |
| 98 |
public function processorInstruction($ele); |
| 99 |
} |
| 100 |
|