Skip to content
Snippets Groups Projects

Issue #3495264: Support custom query options.

Merged Trent Crawford requested to merge issue/apisync-3495264:3495264-modify-select-query into 1.x
2 files
+ 30
0
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 20
0
@@ -44,6 +44,13 @@ class SelectQuery implements SelectQueryInterface {
*/
protected array $conditions = [];
/**
* Custom query parameters.
*
* @var array
*/
protected array $customQueryParameters = [];
/**
* Constructor for a SelectQuery object.
*
@@ -81,6 +88,11 @@ class SelectQuery implements SelectQueryInterface {
public function __toString(): string {
$query = $this->objectType . '?';
if ($this->customQueryParameters) {
// There will always be a $select parameter, so we need to append to it.
$query .= http_build_query($this->customQueryParameters) . '&';
}
if ($this->fields) {
$query .= '$select=' . implode(',', array_unique($this->fields));
}
@@ -168,4 +180,12 @@ class SelectQuery implements SelectQueryInterface {
$this->conditions[] = $condition;
}
/**
* {@inheritdoc}
*/
public function addCustomQueryParameter(string $key, string $value): void {
// The query may be opened in a browser (e.g. for debugging purposes).
$this->customQueryParameters[$key] = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
}
}
Loading