1 | <?php |
||
8 | abstract class BufferBase { |
||
9 | |||
10 | /** |
||
11 | * The the array of buffers. |
||
12 | * |
||
13 | * @var \SplObjectStorage[] |
||
14 | */ |
||
15 | protected $buffers = []; |
||
16 | |||
17 | /** |
||
18 | * The array of result sets. |
||
19 | * |
||
20 | * @var \SplObjectStorage[] |
||
21 | */ |
||
22 | protected $results = []; |
||
23 | |||
24 | /** |
||
25 | * @param object $item |
||
26 | * The item to get the buffer id for. |
||
27 | * @return string |
||
28 | * The buffer id. |
||
29 | */ |
||
30 | protected function getBufferId($item) { |
||
33 | |||
34 | /** |
||
35 | * Helper function to create a resolver for a singular buffer. |
||
36 | * |
||
37 | * @param object $item |
||
38 | * The item to add to the buffer. |
||
39 | * |
||
40 | * @return \Closure |
||
41 | * The callback to invoke to load the result for this buffer item. |
||
42 | */ |
||
43 | protected function createBufferResolver($item) { |
||
59 | |||
60 | /** |
||
61 | * Creates a callback to invoke to load the result for this buffer item. |
||
62 | * |
||
63 | * @param object $item |
||
64 | * The item to add to create the resolver for. |
||
65 | * @param \SplObjectStorage $buffer |
||
66 | * The buffer. |
||
67 | * @param \SplObjectStorage $result |
||
68 | * The result set. |
||
69 | * |
||
70 | * @return \Closure |
||
71 | * The callback to invoke to load the result for this buffer item. |
||
72 | */ |
||
73 | protected function createResolver($item, \SplObjectStorage $buffer, \SplObjectStorage $result) { |
||
79 | |||
80 | /** |
||
81 | * Returns the result of the given item after processing the buffer if needed. |
||
82 | * |
||
83 | * @param object $item |
||
84 | * The buffer item to retrieve the result for. |
||
85 | * @param \SplObjectStorage $buffer |
||
86 | * The buffer. |
||
87 | * @param \SplObjectStorage $result |
||
88 | * The result set. |
||
89 | * |
||
90 | * @return mixed |
||
91 | * The result of resolving the given buffer item. |
||
92 | */ |
||
93 | protected function resolveItem($item, \SplObjectStorage $buffer, \SplObjectStorage $result) { |
||
108 | |||
109 | /** |
||
110 | * Resolves the given buffer wholly. |
||
111 | * |
||
112 | * @param \SplObjectStorage $buffer |
||
113 | * The buffer to be resolved wholly. |
||
114 | * |
||
115 | * @return \SplObjectStorage |
||
116 | * The resolved results for the given buffer, keyed by the corresponding |
||
117 | * buffer items. |
||
118 | */ |
||
119 | protected function resolveBuffer(\SplObjectStorage $buffer) { |
||
132 | |||
133 | /** |
||
134 | * Resolve the buffer as an array. |
||
135 | * |
||
136 | * Simplifies sub-class implementations by concealing the object storage |
||
137 | * details of the buffer object. |
||
138 | * |
||
139 | * @param array $buffer |
||
140 | * The buffer as an array. |
||
141 | * |
||
142 | * @return array |
||
143 | * The resolved results, keyed by their corresponding buffer item array key. |
||
144 | */ |
||
145 | protected function resolveBufferArray(array $buffer) { |
||
148 | } |