Skip to content
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

Adding a paging factory (KnpPaginatorFactory) for users of the paginator components of KNP -components #225

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

skineur
Copy link

@skineur skineur commented Dec 11, 2015

How to use with Knp-Components Pager

use Hateoas\Representation\Factory\KnpPaginatorFactory;
use Hateoas\Configuration\Route;
use new Knp\Component\Pager\Paginator;

    // KnpPaginator component
    $pager = Paginator();
    $paginated = $pager->paginate($some, 1, 10);

    $factory = new KnpPaginatorFactory();
    $paginatedCollection= $factory->createRepresentation($paginated, new Route('my_route_name', array()));

    $json = $hateoas->serialize($paginatedCollection, 'json');
    $xml  = $hateoas->serialize($paginatedCollection, 'xml');

@willdurand
Copy link
Owner

Is this lib still maintained?

@skineur
Copy link
Author

skineur commented Dec 11, 2015

this lib is maintained by KnpLabs. On symfony bundle it exist KnpPaginatorBundle based on this lib

@willdurand
Copy link
Owner

Alright. So let's fix the tests first, and then squash the commits so that we can get this merged :)

@@ -26,7 +26,9 @@
"symfony/routing": "~2.0 || ~3.0",
"symfony/dependency-injection": "~2.0 || ~3.0",
"pagerfanta/pagerfanta": "~1.0",
"twig/twig": "~1.12"
"twig/twig": "~1.12",
"symfony/event-dispatcher": "~2.5",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sf 3?

@adrienbrault
Copy link
Contributor

Looks good!

This can be helpful for the timeline bundle that ships with knp paginator support: https://github.com/stephpy/timeline-bundle/blob/master/Resources/doc/pagination.markdown

@skineur
Copy link
Author

skineur commented Jan 22, 2016

I saw a issue that talked about how to integrate knp paginator to create a representation of collection. Now it is true that it is not very useful on this library.

Thank you I will rather create a gist

@jcornide
Copy link

I saw a issue that talked about how to integrate knp paginator to create a representation of collection. Now it is true that it is not very useful on this library.

hi, @skineur what is the issue you're talking about? why this hasn't been merged? I would found it quite useful

@@ -26,7 +26,9 @@
"symfony/routing": "~2.0 || ~3.0",
"symfony/dependency-injection": "~2.0 || ~3.0",
"pagerfanta/pagerfanta": "~1.0",
"twig/twig": "~1.12"
"twig/twig": "~1.12",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about twig 2?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants