Skip to content

Commit

Permalink
Add DEFAULT_PAGE constant
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Oct 23, 2020
1 parent bc9bb83 commit 94914ea
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Xhgui/Controller/RunController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public function index(Request $request, Response $response)

$result = $this->searcher->getAll([
'sort' => $sort,
'page' => $request->get('page'),
'direction' => $request->get('direction'),
'perPage' => $this->app->config('page.limit'),
'page' => (int)$request->get('page', SearcherInterface::DEFAULT_PAGE),
'direction' => $request->get('direction', SearcherInterface::DEFAULT_DIRECTION),
'perPage' => (int)$this->app->config('page.limit'),
'conditions' => $search,
'projection' => true,
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Xhgui/Searcher/PdoSearcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function getAvgsForUrl($url, $search = [])
public function getAll($options = [])
{
$page = (int)$options['page'];
$direction = $options['direction'] ?? SearcherInterface::DEFAULT_DIRECTION;
$direction = $options['direction'];
if ($page < 1) {
$page = 1;
}
Expand Down
1 change: 1 addition & 0 deletions src/Xhgui/Searcher/SearcherInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
interface SearcherInterface
{
const DEFAULT_DIRECTION = 'desc';
const DEFAULT_PAGE = 1;

/**
* Get the latest profile data.
Expand Down

0 comments on commit 94914ea

Please sign in to comment.