Skip to content
Snippets Groups Projects
Commit 6ff7500b authored by Dimitris Bozelos's avatar Dimitris Bozelos
Browse files

Issue #3357797 Added support for custom filters in list imports

parent ea64b7c8
Branches
Tags
No related merge requests found
......@@ -73,7 +73,7 @@ class ObjectClient implements ClientInterface {
[],
[
'select' => $this->buildOdataOption('select', $options['odata']),
'filter' => $this->buildOdataFilter($filters),
'filter' => $this->buildOdataFilter($filters, $options['odata']),
'expand' => $this->buildOdataOption('expand', $options['odata']),
]
)
......@@ -170,6 +170,8 @@ class ObjectClient implements ClientInterface {
*
* @param array $filters
* The filters passed to this client.
* @param array $options
* The oData options passed to this client.
*
* @return string|null
* The option formatted as expected by OData v3.0 URL conventions, or NULL
......@@ -179,13 +181,9 @@ class ObjectClient implements ClientInterface {
* type : improvement
* priority : normal
* labels : client, odata
* @I Support custom filters in client options
* type : feature
* priority : normal
* labels : client, odata
* phpcs:enable
*/
protected function buildOdataFilter(array $filters): ?string {
protected function buildOdataFilter(array $filters, array $options): ?string {
// Currently we only support one filter group with the `and` operator. We
// need to study the OData protocol a bit more before we can add proper
// support for more groups/operators.
......@@ -207,6 +205,17 @@ class ObjectClient implements ClientInterface {
));
}
// Add other filters.
if (isset($options['filter'])) {
foreach ($options['filter'] as $filter) {
$odata_filter->add(new Filter(
$filter['key'],
$filter['value'],
$filter['operator']
));
}
}
$formatted_odata_filter = (string) $odata_filter;
if ($formatted_odata_filter === '') {
return NULL;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment