{"issue":{"milestone":null,"user":{"id":424343,"login":"Partugal","url":"https://api.github.com/users/Partugal","avatar_url":"https://secure.gravatar.com/avatar/b395eac2a7e05dda08348228ec830d72?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"b395eac2a7e05dda08348228ec830d72"},"title":"pass limit, and offset to CountQuery","created_at":"2011-12-15T19:42:19Z","labels":[],"updated_at":"2011-12-16T13:07:49Z","state":"open","id":2571408,"html_url":"https://github.com/KnpLabs/KnpPaginatorBundle/issues/70","closed_at":null,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"body":"so it is now impossible to determine the count items and query items in one query.\r\nalso impossible set the query result, for example here (https://github.com/KnpLabs/KnpPaginatorBundle/blob/master/Resources/doc/custom_pagination_subscribers.md) this value is stored in the listener, I think this is very wrong, maybe it's worth it unite in one event?\r\n\r\n","number":70,"url":"https://api.github.com/repos/KnpLabs/KnpPaginatorBundle/issues/70","comments":2,"assignee":null},"comment":{"user":{"id":424343,"login":"Partugal","url":"https://api.github.com/users/Partugal","avatar_url":"https://secure.gravatar.com/avatar/b395eac2a7e05dda08348228ec830d72?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"b395eac2a7e05dda08348228ec830d72"},"created_at":"2011-12-16T13:07:49Z","updated_at":"2011-12-16T13:07:49Z","id":3176957,"body":"\r\n```php\r\n<?php\r\n\r\nnamespace Acme\\DemoBundle\\Subscriber;\r\n\r\nuse Symfony\\Component\\Finder\\Finder;\r\nuse Symfony\\Component\\EventDispatcher\\EventSubscriberInterface;\r\nuse Knp\\Component\\Pager\\Event\\CountEvent;\r\nuse Knp\\Component\\Pager\\Event\\ItemsEvent;\r\n\r\nclass PaginateDirectorySubscriber implements EventSubscriberInterface\r\n{\r\n    private $items;\r\n\r\n    public function count(CountEvent $event)\r\n    {\r\n        if ($event->target instanceof MyQuery) {\r\n            $event->target->setLimit(15); // no limit privided\r\n            $event->target->setOffset(15); // no offset provided\r\n            $result = $event->target->execute();\r\n\r\n            $event->count = $result->getTotalFound();\r\n            $event->stopPropagation();\r\n\r\n            $this->items = $result->getItems();\r\n        }\r\n    }\r\n\r\n    public function items(ItemsEvent $event)\r\n    {\r\n        if (($event->target instanceof MyQuery)) {\r\n            $event->items = $this->items;\r\n            $event->stopPropagation();\r\n        }\r\n    }\r\n\r\n    public static function getSubscribedEvents()\r\n    {\r\n        return array(\r\n            'knp_pager.items' => array('items', 1/*increased priority to override any internal*/),\r\n            'knp_pager.count' => array('count', 1/*increased priority*/)\r\n        );\r\n    }\r\n}\r\n```\r\n\r\nin this code I would like to execute query one time: $result = $event->target->execute();\r\nbut limit and offset not exists in Count Event\r\n\r\n","url":"https://api.github.com/repos/KnpLabs/KnpPaginatorBundle/issues/comments/3176957"},"action":"created"}