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

[2.1.x] Added new feature for pagination and also optional sets the aliases #10985

Closed
wants to merge 2 commits into
base: 2.1.x
from

Conversation

Projects
6 participants
@KorsaR-ZN
Copy link
Contributor

KorsaR-ZN commented Sep 29, 2015

Maintain compatibility with version 2.0.x
see #10957

$repository = new \Phalcon\Paginator\Repository();
$repository->setAliases(array(
    'myFirstPage' => $repository::PROPERTY_FIRST_PAGE,
    'myLastPage' => $repository::PROPERTY_LAST_PAGE,
    'myCurrentPage' => $repository::PROPERTY_CURRENT_PAGE
));

$paginator = new \Phalcon\Paginator\Adapter\NativeArray(array(
    'data' => array_fill(0, 30, 'banana'),
    'limit'=> 25,
    'page' => 1,
    'repository' => $repository
));

$page = $paginator->getPaginate();

// First page
echo $page->first . PHP_EOL; // compatibility with version 2.0.x
echo $page->getFirstPage() . PHP_EOL; // Getter
echo $page->firstPage . PHP_EOL; // Magic getter
echo $page->myFirstPage . PHP_EOL; // Alias

// Current page
echo $page->current . PHP_EOL; // compatibility with version 2.0.x
echo $page->getCurrentPage() . PHP_EOL; // Getter
echo $page->currentPage . PHP_EOL; // Magic getter
echo $page->myCurrentPage . PHP_EOL; // Alias

// Last page
echo $page->last . PHP_EOL; // compatibility with version 2.0.x
echo $page->getLastPage() . PHP_EOL; // Getter
echo $page->lastPage . PHP_EOL; // Magic getter
echo $page->myLastPage . PHP_EOL; // Alias

KorsaR-ZN added some commits Sep 29, 2015

@andresgutierrez

This comment has been minimized.

Copy link
Member

andresgutierrez commented Sep 29, 2015

Why introduce a new class?

@KorsaR-ZN

This comment has been minimized.

Copy link
Contributor Author

KorsaR-ZN commented Sep 29, 2015

@andresgutierrez This can be useful for the type-hinting:
In order not to transmit the paginator fully in function, but only a concrete state

function renderPage(\Phalcon\Paginator\RepositoryInterface $page) 
{
    //...expr...
}

//...expr...

$page = $paginator->getPaginate();
$pageRendred = renderPage($page);

//...expr...

or eg for serialization concrete page to transfer anywhere

@sergeyklay

This comment has been minimized.

Copy link
Member

sergeyklay commented Mar 13, 2016

@KorsaR-ZN The 2.1.x branch is best place for this

@Green-Cat

This comment has been minimized.

Copy link
Contributor

Green-Cat commented Mar 13, 2016

This is already targeting 2.1.x. It does need to be rebased though.

@sergeyklay

This comment has been minimized.

Copy link
Member

sergeyklay commented Mar 13, 2016

Oh, yes. Could you please rebase?

@sjinks sjinks closed this Apr 26, 2017

@sjinks sjinks reopened this Apr 26, 2017

@sergeyklay

This comment has been minimized.

Copy link
Member

sergeyklay commented Apr 26, 2017

ping @KorsaR-ZN

@niden

This comment has been minimized.

Copy link
Member

niden commented Dec 12, 2018

@KorsaR-ZN @CameronHall Thank you both. This has been addressed/cherry-picked in

#13653

@niden niden closed this Dec 12, 2018

@niden niden moved this from In progress to Done in 4.0 Release Dec 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment