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