days: refactor for better typing
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/877/head
parent
cb12398893
commit
1752396bf8
|
@ -52,8 +52,8 @@ return [
|
||||||
|
|
||||||
// API Routes
|
// API Routes
|
||||||
['name' => 'Days#days', 'url' => '/api/days', 'verb' => 'GET'],
|
['name' => 'Days#days', 'url' => '/api/days', 'verb' => 'GET'],
|
||||||
['name' => 'Days#day', 'url' => '/api/days/{id}', 'verb' => 'GET'],
|
['name' => 'Days#day', 'url' => '/api/days', 'verb' => 'POST'],
|
||||||
['name' => 'Days#dayPost', 'url' => '/api/days', 'verb' => 'POST'],
|
['name' => 'Days#dayGet', 'url' => '/api/days/{id}', 'verb' => 'GET'],
|
||||||
['name' => 'Folders#sub', 'url' => '/api/folders/sub', 'verb' => 'GET'],
|
['name' => 'Folders#sub', 'url' => '/api/folders/sub', 'verb' => 'GET'],
|
||||||
|
|
||||||
['name' => 'Clusters#list', 'url' => '/api/clusters/{backend}', 'verb' => 'GET'],
|
['name' => 'Clusters#list', 'url' => '/api/clusters/{backend}', 'verb' => 'GET'],
|
||||||
|
|
|
@ -61,13 +61,12 @@ class DaysController extends GenericApiController
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*
|
*
|
||||||
* @PublicPage
|
* @PublicPage
|
||||||
|
*
|
||||||
|
* @param int[] $dayIds
|
||||||
*/
|
*/
|
||||||
public function day(string $id): Http\Response
|
public function day(array $dayIds): Http\Response
|
||||||
{
|
{
|
||||||
return Util::guardEx(function () use ($id) {
|
return Util::guardEx(function () use ($dayIds) {
|
||||||
// Split at commas and convert all parts to int
|
|
||||||
$dayIds = array_map(static fn ($p) => (int) $p, explode(',', $id));
|
|
||||||
|
|
||||||
// Run actual query
|
// Run actual query
|
||||||
$list = $this->tq->getDay(
|
$list = $this->tq->getDay(
|
||||||
$dayIds,
|
$dayIds,
|
||||||
|
@ -91,12 +90,11 @@ class DaysController extends GenericApiController
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*
|
*
|
||||||
* @PublicPage
|
* @PublicPage
|
||||||
*
|
|
||||||
* @param int[] $dayIds
|
|
||||||
*/
|
*/
|
||||||
public function dayPost(array $dayIds): Http\Response
|
public function dayGet(string $id): Http\Response
|
||||||
{
|
{
|
||||||
return $this->day(implode(',', $dayIds));
|
// Split at commas and convert all parts to int
|
||||||
|
return $this->day(array_map(static fn ($p) => (int) $p, explode(',', $id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue