1
0
Fork 0
mirror of https://codeberg.org/demostf/api.git synced 2026-06-03 18:04:08 +02:00

cast in controller

This commit is contained in:
Robin Appelman 2017-08-07 22:57:44 +02:00
commit 54260646e0

View file

@ -71,39 +71,39 @@ class DemoController extends BaseController {
public function listDemos() { public function listDemos() {
$page = $this->query('page', 1); $page = $this->query('page', 1);
$order = $this->query('order', 'DESC') === 'ASC' ? 'ASC' : 'DESC'; $order = $this->query('order', 'DESC') === 'ASC' ? 'ASC' : 'DESC';
\Flight::json($this->demoListProvider->listDemos($page, $this->getFilter(), $order)); \Flight::json($this->demoListProvider->listDemos((int)$page, $this->getFilter(), $order));
} }
public function listProfile($steamId) { public function listProfile($steamId) {
$page = $this->query('page', 1); $page = $this->query('page', 1);
$where = $this->getFilter(); $where = $this->getFilter();
$where['players'][] = $steamId; $where['players'][] = $steamId;
\Flight::json($this->demoListProvider->listProfile($page, $where)); \Flight::json($this->demoListProvider->listProfile((int)$page, $where));
} }
public function listUploads($steamId) { public function listUploads($steamId) {
$page = $this->query('page', 1); $page = $this->query('page', 1);
\Flight::json($this->demoListProvider->listUploads($steamId, $page, $this->getFilter())); \Flight::json($this->demoListProvider->listUploads($steamId, (int)$page, $this->getFilter()));
} }
public function chat($demoId) { public function chat($demoId) {
\Flight::json($this->chatProvider->getChat($demoId)); \Flight::json($this->chatProvider->getChat((int)$demoId));
} }
public function setDemoUrl($id) { public function setDemoUrl($id) {
$hash = (string) $this->post('hash', ''); $hash = (string)$this->post('hash', '');
$backend = (string) $this->post('backend', ''); $backend = (string)$this->post('backend', '');
$path = (string) $this->post('path', ''); $path = (string)$this->post('path', '');
$url = (string) $this->post('url', ''); $url = (string)$this->post('url', '');
$editKey = (string) $this->post('key', ''); $editKey = (string)$this->post('key', '');
if ($editKey !== $this->editKey || $editKey === '') { if ($editKey !== $this->editKey || $editKey === '') {
throw new \InvalidArgumentException('Invalid key'); throw new \InvalidArgumentException('Invalid key');
} }
$demo = $this->demoProvider->get((int) $id); $demo = $this->demoProvider->get((int)$id);
$existingHash = $demo->getHash(); $existingHash = $demo->getHash();
if ($existingHash === '' || $existingHash === $hash) { if ($existingHash === '' || $existingHash === $hash) {
$this->demoProvider->setDemoUrl((int) $id, $backend, $url, $path); $this->demoProvider->setDemoUrl((int)$id, $backend, $url, $path);
} else { } else {
throw new \InvalidArgumentException('Invalid demo hash'); throw new \InvalidArgumentException('Invalid demo hash');
} }