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

Appending the Paginator tree walker hint #716

Merged
merged 4 commits into from
Aug 10, 2013
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/Doctrine/ORM/Tools/Pagination/Paginator.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function count()
$countQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\CountOutputWalker');
$countQuery->setResultSetMapping($rsm);
} else {
$countQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\CountWalker'));
$this->appendTreeWalker($countQuery, 'Doctrine\ORM\Tools\Pagination\CountWalker');
}

$countQuery->setFirstResult(null)->setMaxResults(null);
Expand Down Expand Up @@ -165,7 +165,7 @@ public function getIterator()
if ($this->useOutputWalker($subQuery)) {
$subQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker');
} else {
$subQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\LimitSubqueryWalker'));
$this->appendTreeWalker($subQuery, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryWalker');
}

$subQuery->setFirstResult($offset)->setMaxResults($length);
Expand Down Expand Up @@ -231,4 +231,16 @@ private function useOutputWalker(Query $query)

return $this->useOutputWalkers;
}

private function appendTreeWalker(Query $query, $walkerClass)
Copy link
Member

Choose a reason for hiding this comment

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

Missing docblock

{
$hints = $query->getHint(Query::HINT_CUSTOM_TREE_WALKERS);

if ($hints === false) {
$hints = array();
}

$hints[] = $walkerClass;
$query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, $hints);
}
}