Skip to content

Commit

Permalink
Added option of setting query hints
Browse files Browse the repository at this point in the history
  • Loading branch information
juniwalk authored and f3l1x committed Sep 26, 2022
1 parent 643ab46 commit f64403e
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/DataSource/DoctrineDataSource.php
Expand Up @@ -57,6 +57,11 @@ class DoctrineDataSource extends FilterableDataSource implements IDataSource, IA
*/
protected $placeholder;

/**
* @var array<string, mixed>
*/
protected $hints = [];


public function __construct(QueryBuilder $dataSource, string $primaryKey)
{
Expand All @@ -66,9 +71,26 @@ public function __construct(QueryBuilder $dataSource, string $primaryKey)
}


/**
* @param mixed $value
*/
public function setQueryHint(string $name, $value): IDataSource
{
$this->hints[$name] = $value;

return $this;
}


public function getQuery(): Query
{
return $this->dataSource->getQuery();
$query = $this->dataSource->getQuery();

foreach ($this->hints as $name => $value) {
$query->setHint($name, $value);
}

return $query;
}


Expand Down

0 comments on commit f64403e

Please sign in to comment.