Skip to content

Commit 43d388d

Browse files
authored
Merge pull request #7 from AppsDevTeam/adt-doctrine-components
Adt doctrine components
2 parents c3c5cc6 + c556c92 commit 43d388d

3 files changed

Lines changed: 20 additions & 31 deletions

File tree

composer.json

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
{
22
"name": "adt/query-object-data-source",
3-
"description": "Ublaboo Datagrid data source bindings for Kdyby Doctrine query objects.",
3+
"description": "Ublaboo Datagrid data source bindings for adt/base-query query objects.",
44
"type": "library",
55
"license": [
6-
"MIT",
7-
"BSD-3-Clause",
8-
"GPL-2.0",
9-
"GPL-3.0"
6+
"MIT"
107
],
118
"require": {
12-
"php": ">=7.1"
13-
},
14-
"require-dev": {
15-
"kdyby/doctrine": "^3.1 || ~4.0",
16-
"ublaboo/datagrid": "^5.0 || ~6.0",
17-
"nette/utils": "^2.4 || ~3.0",
18-
"nette/di": "^2.4 || ~3.0"
9+
"php": ">=7.4",
10+
"adt/base-query": "^2.0",
11+
"ublaboo/datagrid": "^6.0",
12+
"nette/di": "^2.4|^3.0"
1913
},
2014
"autoload": {
2115
"psr-4": {

src/IQueryObjectDataSourceFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
interface IQueryObjectDataSourceFactory {
66

77
/**
8-
* @param \Kdyby\Doctrine\QueryObject $queryObject
9-
* @param \Kdyby\Doctrine\EntityRepository|null $repo
8+
* @param \ADT\DoctrineComponents\QueryObject $queryObject
9+
* @param \Doctrine\ORM\EntityRepository|null $repo
1010
* @return QueryObjectDataSource
1111
*/
12-
function create(\Kdyby\Doctrine\QueryObject $queryObject, \Kdyby\Doctrine\EntityRepository $repo = null);
12+
function create(\ADT\DoctrineComponents\QueryObject $queryObject, \Doctrine\ORM\EntityRepository $repo = null);
1313

1414
}

src/QueryObjectDataSource.php

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,15 @@
1010
use Ublaboo\DataGrid\Utils\DateTimeHelper;
1111
use Ublaboo\DataGrid\DataSource\IDataSource;
1212

13-
class QueryObjectDataSource implements IDataSource {
14-
15-
use \Nette\SmartObject;
16-
17-
/** @var \Kdyby\Doctrine\ResultSet */
13+
class QueryObjectDataSource implements IDataSource
14+
{
15+
/** @var \ADT\DoctrineComponents\ResultSet */
1816
protected $resultSet;
1917

20-
/** @var \Kdyby\Doctrine\EntityRepository */
18+
/** @var \Doctrine\ORM\EntityRepository */
2119
protected $repo;
2220

23-
/** @var \Kdyby\Doctrine\QueryObject|IQueryObject */
21+
/** @var \ADT\DoctrineComponents\QueryObject|IQueryObject */
2422
protected $queryObject;
2523

2624
/** @var callable */
@@ -40,11 +38,11 @@ class QueryObjectDataSource implements IDataSource {
4038

4139
/**
4240
* QueryObjectDataSource constructor.
43-
* @param \Kdyby\Doctrine\QueryObject $queryObject
44-
* @param \Kdyby\Doctrine\EntityRepository|null $repo
41+
* @param \ADT\DoctrineComponents\QueryObject $queryObject
42+
* @param \Doctrine\ORM\EntityRepository|null $repo
4543
* @throws \Exception
4644
*/
47-
public function __construct(\Kdyby\Doctrine\QueryObject $queryObject, \Kdyby\Doctrine\EntityRepository $repo = null)
45+
public function __construct(\ADT\DoctrineComponents\QueryObject $queryObject, \Doctrine\ORM\EntityRepository $repo = null)
4846
{
4947
if (!$repo && (!$queryObject instanceof IQueryObject)) {
5048
throw new \Exception('"repo" must be set or "queryObject" has to implement IQueryObject interface.');
@@ -95,8 +93,7 @@ public function setLimitCallback($callback) {
9593

9694
protected function getResultSet() {
9795
if (!$this->resultSet) {
98-
$this->resultSet = $this->repo
99-
->fetch($this->queryObject);
96+
$this->resultSet = $this->queryObject->fetch();
10097
}
10198

10299
return $this->resultSet;
@@ -107,9 +104,7 @@ protected function getResultSet() {
107104
* @return int
108105
*/
109106
public function getCount(): int {
110-
return $this->repo
111-
->fetch($this->queryObject)
112-
->getTotalCount();
107+
return $this->queryObject->fetch()->getTotalCount();
113108
}
114109

115110
/**
@@ -181,7 +176,7 @@ public function filterOne(array $filter): IDataSource {
181176
* @param int $limit
182177
* @return static
183178
*/
184-
public function limit($offset, $limit): IDataSource {
179+
public function limit(int $offset, int $limit): IDataSource {
185180
$defaultCallback = function () use ($offset, $limit) {
186181
$this->getResultSet()->applyPaging($offset, $limit);
187182
};

0 commit comments

Comments
 (0)