15 private $results =
array();
16 private $filters =
array();
17 private $errors =
array();
18 private $relations =
array();
46 private function isAvailableFilter($filterKey)
50 return in_array($filterKey, $availableFilterKeys);
60 if ($this->isAvailableFilter(
$key))
62 $this->filters[
$key][] = $this->normaliseFilterValue($value);
67 $this->errors[] =
new Error(
'Filter with key:' .
$key .
' not available for this provider');
78 $this->relations[] =
$key;
86 return $this->filters;
94 return $this->relations;
104 $filteredEntityIds = $this->getFilteredValues($indices);
108 if (!empty($filters))
138 if (in_array(
$key, $filteredEntityIds))
157 private function getFilteredValues($indices)
159 $filteredEntityIds =
array();
162 if ($filterType !==
'primary')
164 $newFilterEntityIds =
array();
167 foreach ($filterKey as $filterValue)
169 if (isset($indices[$filterType][$filterValue]))
171 $newFilterEntityIds = array_merge($newFilterEntityIds, $indices[$filterType][$filterValue]);
175 if (!empty($filteredEntityIds))
177 $filteredEntityIds = array_intersect($filteredEntityIds, $newFilterEntityIds);
181 $filteredEntityIds = $newFilterEntityIds;
186 if (!empty($filteredEntityIds))
188 $filteredEntityIds = array_intersect($filteredEntityIds,
$filterValues[0]);
196 return array_unique($filteredEntityIds);
211 private function normaliseFilterValue($value)
213 $result = is_array($value) ? array_unique($value) :
array($value);
225 $processMethodName =
'processWith' . ucfirst($relationName);
243 return array_shift($results);
252 return $this->results;
261 $this->results = $results;