Skip to content

Commit 9f37bb7

Browse files
committed
feat: add ability to provide page length in returnPaginated
1 parent b0e1e63 commit 9f37bb7

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/Controllers/ApiController.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,13 @@ public function failure(array $context = [])
111111
* @param SS_List $list
112112
* @param callable $keyFunc
113113
* @param callable $dataFunc
114+
* @param int $pageLength
114115
*
115116
* @return HTTPResponse
116117
*/
117-
public function returnPaginated(SS_List $list, $keyFunc = null, $dataFunc = null)
118+
public function returnPaginated(SS_List $list, $keyFunc = null, $dataFunc = null, $pageLength = 100)
118119
{
119-
list($list, $output) = $this->prepPaginatedOutput($list, $keyFunc, $dataFunc);
120+
list($list, $output) = $this->prepPaginatedOutput($list, $keyFunc, $dataFunc, $pageLength);
120121

121122
return $this->returnArray([
122123
'records' => $output,
@@ -227,7 +228,8 @@ public function ensureUserLoggedIn($permissionCodes = [])
227228
$token = JWT::decode(
228229
$this->getJwt(),
229230
Config::inst()->get(JWTUtils::class, 'secret'),
230-
['HS256']);
231+
['HS256']
232+
);
231233

232234
$member = Member::get()->byID($token->memberId);
233235

@@ -392,12 +394,12 @@ public function ensureVars(array $vars = [])
392394
foreach ($vars as $k => $v) {
393395
if ($v && is_callable($v)) {
394396
if (!$this->hasVar($k) || !$v($this->getVar($k))) {
395-
throw $this->httpError(400, 'Missing required variable: '. $v);
397+
throw $this->httpError(400, 'Missing required variable: ' . $v);
396398
}
397399

398400
$output[] = $this->getVar($k);
399401
} elseif (!$this->hasVar($v)) {
400-
throw $this->httpError(400, 'Missing required variable: '. $v);
402+
throw $this->httpError(400, 'Missing required variable: ' . $v);
401403
} else {
402404
$output[] = $this->getVar($v);
403405
}

src/Controllers/AuthController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ class AuthController extends ApiController
1212
'verify',
1313
];
1414

15-
private static $test = '123';
16-
1715
/**
1816
* The token is acquired by using basic auth. Once the user has entered the
1917
* username / password and completed this first step then we give them back
2018
* a token which contains their information
2119
*/
22-
public function token() {
20+
public function token()
21+
{
2322
try {
2423
$payload = JWTUtils::inst()->byBasicAuth($this->request);
2524

25+
$this->extend('updatePayload', $payload);
26+
2627
return $this->returnArray($payload);
2728
} catch (JWTUtilsException $e) {
2829
return $this->httpError(403, $e->getMessage());

0 commit comments

Comments
 (0)