Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
apisync
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
apisync
Commits
5a478e61
Commit
5a478e61
authored
5 months ago
by
Trent Crawford
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3495264
by tcrawford: Support custom query options
parent
9b4261bf
Branches
Branches containing commit
Tags
1.0.0-alpha7
Tags containing commit
1 merge request
!4
Issue #3495264: Support custom query options.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/OData/SelectQuery.php
+20
-0
20 additions, 0 deletions
src/OData/SelectQuery.php
src/OData/SelectQueryInterface.php
+10
-0
10 additions, 0 deletions
src/OData/SelectQueryInterface.php
with
30 additions
and
0 deletions
src/OData/SelectQuery.php
+
20
−
0
View file @
5a478e61
...
...
@@ -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'
);
}
}
This diff is collapsed.
Click to expand it.
src/OData/SelectQueryInterface.php
+
10
−
0
View file @
5a478e61
...
...
@@ -91,4 +91,14 @@ interface SelectQueryInterface {
*/
public
function
addBuiltCondition
(
string
|
array
$condition
):
void
;
/**
* Add a custom query parameter.
*
* @param string $key
* The query parameter key.
* @param string $value
* The query parameter value.
*/
public
function
addCustomQueryParameter
(
string
$key
,
string
$value
):
void
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment