-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First fix #92
First fix #92
Conversation
@Orkin please: meaningful commit messages. |
@Ocramius Sorry for my commit message, I was not inspired |
You can change your commit message by doing |
@@ -250,7 +254,11 @@ protected function buildRouteMatch(ResourceInterface $resource, $path) | |||
} | |||
|
|||
// @TODO: for now, collection is always wrapped around a ResourcePaginator, should instead be configurable | |||
$data = new ResourcePaginator($resourceMetadata, new SelectableAdapter($data, $criteria)); | |||
if ($data instanceof EntityRepository && class_exists('DoctrineORMModule/Paginator/Adapter/DoctrinePaginator')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure you should use the namespace separator for class exists.
@@ -250,7 +254,11 @@ protected function buildRouteMatch(ResourceInterface $resource, $path) | |||
} | |||
|
|||
// @TODO: for now, collection is always wrapped around a ResourcePaginator, should instead be configurable | |||
$data = new ResourcePaginator($resourceMetadata, new SelectableAdapter($data, $criteria)); | |||
if ($data instanceof EntityRepository && class_exists('DoctrineORMModule/Paginator/Adapter/DoctrinePaginator')) { | |||
$data = new ResourcePaginator($resourceMetadata, new DoctrineAdapter(new DoctrinePaginator($data->find(array_shift($chunks))))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. In fact it's not that easy. https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/Pagination/Paginator.php#L62
The consrtuctor of Doctrine paginator accepts either a Query or a Query builder. Hhmm... Let me think about it tomorrow.
@@ -250,7 +254,11 @@ protected function buildRouteMatch(ResourceInterface $resource, $path) | |||
} | |||
|
|||
// @TODO: for now, collection is always wrapped around a ResourcePaginator, should instead be configurable | |||
$data = new ResourcePaginator($resourceMetadata, new SelectableAdapter($data, $criteria)); | |||
if ($data instanceof EntityRepository && class_exists('DoctrineORMModule\Paginator\Adapter\DoctrinePaginator')) { | |||
$data = new ResourcePaginator($resourceMetadata, new DoctrineAdapter(new DoctrinePaginator($data->find(array_shift($chunks))))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not handle pagination. The DoctrinePagination of the ORM module works with DQL queries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I realized this. I'm going to close as the logic is broken.
Today I'm going to give a new try to fix that directly in Doctrine ORM.
As discussed with @Ocramius , the fix cannot work in fact, because Doctrine Paginator expects DQL, and we don't have this in ResourceMatch. So the simplest is to solve this directly at Doctrine level. I'll try to come with a PR. |
Use doctrineAdapter in case of using DoctrineORM to prevent this problem : #91
I'm not sure if this is what @bakura10 had in mind.