From 48204d5cf1f1eb1caf7916225a4ab6c4c2ec5b1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Kud=C4=9Blka?= Date: Sat, 28 Nov 2020 22:47:07 +0000 Subject: [PATCH 1/2] Update QueryObjectDataSource.php --- src/QueryObjectDataSource.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/QueryObjectDataSource.php b/src/QueryObjectDataSource.php index b7f3996..86454f1 100644 --- a/src/QueryObjectDataSource.php +++ b/src/QueryObjectDataSource.php @@ -37,12 +37,19 @@ class QueryObjectDataSource implements IDataSource { private $data; /** + * QueryObjectDataSource constructor. * @param \Kdyby\Doctrine\QueryObject $queryObject - * @param \Kdyby\Doctrine\EntityRepository $repo + * @param \Kdyby\Doctrine\EntityRepository|null $repo + * @throws \Exception */ - public function __construct(\Kdyby\Doctrine\QueryObject $queryObject, \Kdyby\Doctrine\EntityRepository $repo) { + public function __construct(\Kdyby\Doctrine\QueryObject $queryObject, \Kdyby\Doctrine\EntityRepository $repo = null) + { + if (!$repo && (!$queryObject instanceof IQueryObject)) { + throw new \Exception('"repo" must be set or "queryObject" has to implement IQueryObject interface.'); + } + $this->queryObject = $queryObject; - $this->repo = $repo; + $this->repo = $repo ?: $queryObject->getEntityManager(); } /** From e384c25126cf642918470ea300116471a6bb51ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Kud=C4=9Blka?= Date: Sat, 28 Nov 2020 22:47:33 +0000 Subject: [PATCH 2/2] Update IQueryObject.php --- src/IQueryObject.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/IQueryObject.php b/src/IQueryObject.php index a2cefd5..6a2fe38 100644 --- a/src/IQueryObject.php +++ b/src/IQueryObject.php @@ -4,11 +4,9 @@ interface IQueryObject { - - function orderBy($column, $value); - - function searchIn($column, $value); + function orderBy(string $column, string $order = 'ASC'); - function equalIn($column, $value); + function searchIn($column, $value, bool $strict = false); + function getEntityManager(); }