Skip to content

Commit 7d2fb6e

Browse files
author
Tomasz Cyrankowski
committed
Changed count() on Cursor
1 parent 30772fc commit 7d2fb6e

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

Grid/Source/Document.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,7 @@ public function execute($columns, $page = 0, $limit = 0, $maxResults = null, $gr
268268
// I really don't know if Cursor is the right type returned (I mean, every single type).
269269
// As I didn't find out this information, I'm gonna test it with Cursor returned only.
270270
$cursor = $this->query->getQuery()->execute();
271-
272-
if ($cursor instanceof \Countable) {
273-
$this->count = $cursor->count();
274-
} else {
275-
$this->count = count($cursor->toArray());
276-
}
271+
$this->count = $cursor->count();
277272

278273
foreach ($cursor as $resource) {
279274
$row = new Row();
@@ -313,19 +308,13 @@ protected function addReferencedColumn(array $subColumn, Column $column)
313308

314309
$cursor = $helperQuery->getQuery()->execute();
315310

316-
if ($cursor instanceof \Countable) {
317-
$count = $cursor->count();
318-
} else {
319-
$count = count($cursor->toArray());
320-
}
321-
322311
foreach ($cursor as $resource) {
323312
// Is this case possible? I don't think so
324-
if ($count > 0) {
313+
if ($cursor->count() > 0) {
325314
$this->query->select($subColumn[0]);
326315
}
327316

328-
if ($count == 1) {
317+
if ($cursor->count() === 1) {
329318
$this->query->field($subColumn[0])->references($resource);
330319
} else {
331320
$this->query->addOr($this->query->expr()->field($subColumn[0])->references($resource));

0 commit comments

Comments
 (0)