Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ class Builder
*/
public $orders;

/**
* The custom options for the query.
*
* @var array
*/
public $customOption;

/**
* The maximum number of records to return.
*
Expand Down Expand Up @@ -244,6 +251,19 @@ public function whereKey($id)
$this->client->setEntityKey($this->entityKey);
return $this;
}

/**
* Add custom option to query parameters.
*
* @param string $options
*
* @return $this
*/
public function addOption($option)
{
$this->customOption = $option;
return $this;
}

/**
* Add an $expand clause to the query.
Expand Down
40 changes: 40 additions & 0 deletions src/Query/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class Grammar implements IGrammar
'expands',
//'search',
'orders',
'customOption',
'skip',
'skiptoken',
'take',
Expand Down Expand Up @@ -392,6 +393,45 @@ protected function compileOrdersToArray(Builder $query, $orders)
}, $orders);
}

/**
* Compile the custom options portion of the query.
*
* @param Builder $query
* @param string $customOption
*
* @return string
*/
protected function compileCustomOption(Builder $query, $customOption)
{
if (is_null($customOption)) {
return '';
}

if (is_array($customOption)) {
$customOption = $this->compileCompositeCustomOption($customOption);
}

return $this->appendQueryParam($customOption);
}

/**
* Compile the composite Custom Options key portion of the query.
*
* @param Builder $query
* @param mixed $customOption
*
* @return string
*/
public function compileCompositeCustomOption($customOption)
{
$customOptions = [];
foreach ($customOption as $key => $value) {
$customOptions[] = $key . '=' . $value;
}

return implode(',', $customOptions);
}

/**
* Compile the "$top" portions of the query.
*
Expand Down