Total Complexity | 12 |
Total Lines | 68 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
10 | abstract class SearchIndex_Recording extends SearchIndex |
||
11 | { |
||
12 | public $added = array(); |
||
13 | public $deleted = array(); |
||
14 | public $committed = false; |
||
15 | |||
16 | public function reset() |
||
17 | { |
||
18 | $this->added = array(); |
||
19 | $this->deleted = array(); |
||
20 | $this->committed = false; |
||
21 | } |
||
22 | |||
23 | public function add($object) |
||
24 | { |
||
25 | $res = array(); |
||
26 | |||
27 | $res['ID'] = $object->ID; |
||
28 | |||
29 | foreach ($this->getFieldsIterator() as $name => $field) { |
||
30 | $val = $this->_getFieldValue($object, $field); |
||
31 | $res[$name] = $val; |
||
32 | } |
||
33 | |||
34 | $this->added[] = $res; |
||
35 | } |
||
36 | |||
37 | public function getAdded($fields = array()) |
||
38 | { |
||
39 | $res = array(); |
||
40 | |||
41 | foreach ($this->added as $added) { |
||
42 | $filtered = array(); |
||
43 | foreach ($fields as $field) { |
||
44 | if (isset($added[$field])) { |
||
45 | $filtered[$field] = $added[$field]; |
||
46 | } |
||
47 | } |
||
48 | $res[] = $filtered; |
||
49 | } |
||
50 | |||
51 | return $res; |
||
52 | } |
||
53 | |||
54 | public function delete($base, $id, $state) |
||
55 | { |
||
56 | $this->deleted[] = array('base' => $base, 'id' => $id, 'state' => $state); |
||
57 | } |
||
58 | |||
59 | public function commit() |
||
60 | { |
||
61 | $this->committed = true; |
||
62 | } |
||
63 | |||
64 | public function getIndexName() |
||
65 | { |
||
66 | return get_class($this); |
||
67 | } |
||
68 | |||
69 | public function getIsCommitted() |
||
70 | { |
||
71 | return $this->committed; |
||
72 | } |
||
73 | |||
74 | public function getService() |
||
78 | } |
||
79 | } |
||
80 |