Closed oleg-andreyev closed 5 years ago
DatagridInterface::getResults
declare return typearray
PagerInterface::getResults
declare return typearray
I found, that Sonata\AdminBundle\Datagrid\Datagrid::getResults
may return instance of Doctrine\ODM\MongoDB\Cursor
when using DoctrineMongoDBAdminBundle, i.e. Datagrid::getResults recieves non-array (mixed) value from $this->pager->getResults()
!
DoctrineMongoDBAdminBundle
does not use SimplePager, but DoctrinePHPCRAdminBundle
does. So, maybe pager for DoctrinePHPCRAdminBundle
returns ArrayCollection
? I cannot check it by myself =(
array
will be returns if empty result
That condition is not about empty result:
if (count($this->results) > $this->getMaxPerPage()) {
// ... skipped ...
} else {
$this->haveToPaginate = false;
// ^ it is not empty result, it is "result does not have to be paginated"
}
@covex-nn thanks for your feedback, I'll investigate.
@covex-nn SimplePager
will never work with MongoDB, array_slice
accepts array
and does not work with \Iterator
, which seems to as separate bug to fill.
I've investigated PHPCR, and yes it's returning ArrayCollection, so I've adjusted SimplePager to handle such cases
Closing since #5137 is already merged. Thank you!
Environment
Any
Sonata packages
Symfony packages
PHP version
Subject
Issue was moved with #2656 from SonataDoctrinePhpcrAdminBundle
DatagridInterface::getResults
declare return typearray
PagerInterface::getResults
declare return typearray
SimplePager
may returnmixed
(array or collection)array
will be returns if empty resultArrayCollection
will be returns if non-empty result