1 | <?php |
||
15 | abstract class AbstractListenerBase |
||
16 | { |
||
17 | /** |
||
18 | * Object persister. |
||
19 | * |
||
20 | * @var ObjectPersisterInterface |
||
21 | */ |
||
22 | protected $objectPersister; |
||
23 | |||
24 | /** |
||
25 | * Configuration for the listener. |
||
26 | * |
||
27 | * @var array |
||
28 | */ |
||
29 | private $config; |
||
30 | |||
31 | /** |
||
32 | * Objects scheduled for insertion. |
||
33 | * |
||
34 | * @var array |
||
35 | */ |
||
36 | public $scheduledForInsertion = array(); |
||
37 | |||
38 | /** |
||
39 | * Objects scheduled to be updated or removed. |
||
40 | * |
||
41 | * @var array |
||
42 | */ |
||
43 | public $scheduledForUpdate = array(); |
||
44 | |||
45 | /** |
||
46 | * IDs of objects scheduled for removal. |
||
47 | * |
||
48 | * @var array |
||
49 | */ |
||
50 | public $scheduledForDeletion = array(); |
||
51 | |||
52 | /** |
||
53 | * PropertyAccessor instance. |
||
54 | * |
||
55 | * @var PropertyAccessorInterface |
||
56 | */ |
||
57 | protected $propertyAccessor; |
||
58 | |||
59 | /** |
||
60 | * @var IndexableInterface |
||
61 | */ |
||
62 | private $indexable; |
||
63 | |||
64 | /** |
||
65 | * Constructor. |
||
66 | * |
||
67 | * @param ObjectPersisterInterface $objectPersister |
||
68 | * @param IndexableInterface $indexable |
||
69 | * @param array $config |
||
70 | * @param LoggerInterface $logger |
||
71 | */ |
||
72 | 8 | public function __construct( |
|
89 | |||
90 | /** |
||
91 | * Persist scheduled objects to ElasticSearch |
||
92 | * After persisting, clear the scheduled queue to prevent multiple data updates when using multiple flush calls. |
||
93 | */ |
||
94 | private function persistScheduled() |
||
109 | |||
110 | /** |
||
111 | * Iterating through scheduled actions *after* flushing ensures that the |
||
112 | * ElasticSearch index will be affected only if the query is successful. |
||
113 | */ |
||
114 | protected function doPostFlush() |
||
118 | |||
119 | /** |
||
120 | * Record the specified identifier to delete. Do not need to entire object. |
||
121 | * |
||
122 | * @param object $object |
||
123 | */ |
||
124 | private function scheduleForDeletion($object) |
||
130 | |||
131 | /** |
||
132 | * Checks if the object is indexable or not. |
||
133 | * |
||
134 | * @param object $object |
||
135 | * |
||
136 | * @return bool |
||
137 | */ |
||
138 | private function isObjectIndexable($object) |
||
146 | |||
147 | /** |
||
148 | * Looks for new objects that should be indexed. |
||
149 | * |
||
150 | * @param object $entity |
||
151 | */ |
||
152 | protected function doPostPersist($entity) |
||
158 | |||
159 | /** |
||
160 | * Looks for objects being updated that should be indexed or removed from the index. |
||
161 | * |
||
162 | * @param object $entity |
||
163 | */ |
||
164 | protected function doPostUpdate($entity) |
||
175 | |||
176 | /** |
||
177 | * Delete objects preRemove instead of postRemove so that we have access to the id. Because this is called |
||
178 | * preRemove, first check that the entity is managed by persister. |
||
179 | * |
||
180 | * @param object $entity |
||
181 | */ |
||
182 | protected function doPreRemove($entity) |
||
188 | } |
||
189 |