Basic search API integration.
[sandbox/serialjaywalker/1195272.git] / modules / search / modules / order / includes / commerce_pos_order_search_pos_filter.inc
1 <?php
2
3 /**
4 * Data alteration callback that filters out non-POS Commerce orders.
5 */
6 class CommercePosOrderSearchPosFilter extends SearchApiAbstractAlterCallback {
7
8 /**
9 * @param SearchApiIndex $index
10 * @return bool
11 */
12 public function supportsIndex(SearchApiIndex $index) {
13 return in_array($index->item_type, array('commerce_order'));
14 }
15
16 /**
17 * Exclude items that doesn't have a product reference field attached to
18 * the bundle.
19 */
20 public function alterItems(array &$items) {
21 $statuses = commerce_pos_order_statuses();
22 foreach ($items as $id => $item) {
23 if (empty($statuses[$item->status])) {
24 unset($items[$id]);
25 }
26 }
27 }
28 }