| @@ 45-64 (lines=20) @@ | ||
| 42 | * @param array $conditions key: condition, value: value: int / string / int[] / string[] |
|
| 43 | * @return LocationCollection |
|
| 44 | */ |
|
| 45 | public function matchLocation(array $conditions) |
|
| 46 | { |
|
| 47 | $this->validateConditions($conditions); |
|
| 48 | ||
| 49 | foreach ($conditions as $key => $values) { |
|
| 50 | ||
| 51 | $query = new LocationQuery(); |
|
| 52 | $query->limit = self::INT_MAX_16BIT; |
|
| 53 | if (isset($query->performCount)) $query->performCount = false; |
|
| 54 | $query->filter = $this->getQueryCriterion($key, $values); |
|
| 55 | $results = $this->repository->getSearchService()->findLocations($query); |
|
| 56 | ||
| 57 | $locations = []; |
|
| 58 | foreach ($results->searchHits as $result) { |
|
| 59 | $locations[$result->valueObject->id] = $result->valueObject; |
|
| 60 | } |
|
| 61 | ||
| 62 | return new LocationCollection($locations); |
|
| 63 | } |
|
| 64 | } |
|
| 65 | ||
| 66 | /** |
|
| 67 | * When matching by key, we accept location Id and remote Id only |
|
| @@ 42-61 (lines=20) @@ | ||
| 39 | * @todo test all supported matching conditions |
|
| 40 | * @todo support matching by item_id |
|
| 41 | */ |
|
| 42 | public function matchItem(array $conditions) |
|
| 43 | { |
|
| 44 | $this->validateConditions($conditions); |
|
| 45 | ||
| 46 | foreach ($conditions as $key => $values) { |
|
| 47 | ||
| 48 | $query = new Query(); |
|
| 49 | $query->limit = self::INT_MAX_16BIT; |
|
| 50 | if (isset($query->performCount)) $query->performCount = false; |
|
| 51 | $query->filter = $this->getQueryCriterion($key, $values); |
|
| 52 | $results = $this->repository->getTrashService()->findTrashItems($query); |
|
| 53 | ||
| 54 | $items = []; |
|
| 55 | foreach ($results->items as $result) { |
|
| 56 | $items[$result->id] = $result; |
|
| 57 | } |
|
| 58 | ||
| 59 | return new TrashedItemCollection($items); |
|
| 60 | } |
|
| 61 | } |
|
| 62 | } |
|
| 63 | ||