mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 18:04:08 +02:00
upload framework
This commit is contained in:
parent
754b1ce108
commit
a1a9504f11
30 changed files with 1578 additions and 155 deletions
81
src/Controllers/DemoController.php
Normal file
81
src/Controllers/DemoController.php
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
<?php namespace Demostf\API\Controllers;
|
||||
|
||||
use Demostf\API\Providers\DemoProvider;
|
||||
use Demostf\API\Providers\MatchProvider;
|
||||
|
||||
class DemoController extends BaseController {
|
||||
|
||||
/**
|
||||
* @var \Providers\DemoProvider
|
||||
*/
|
||||
private $demoProvider;
|
||||
|
||||
public function __construct(DemoProvider $demoProvider) {
|
||||
$this->demoProvider = $demoProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
*/
|
||||
public function get($id) {
|
||||
\Flight::json($this->demoProvider->get($id));
|
||||
}
|
||||
|
||||
protected function getFilter() {
|
||||
$map = $this->query('map', '');
|
||||
$players = $this->query('players', '');
|
||||
$type = $this->query('type', '');
|
||||
$filter = [];
|
||||
if ($map) {
|
||||
$filter['map'] = $map;
|
||||
}
|
||||
if ($players) {
|
||||
if (!is_array($players)) {
|
||||
$players = explode(',', $players);
|
||||
}
|
||||
$players = array_filter($players);
|
||||
$filter['players'] = $players;
|
||||
}
|
||||
switch ($type) {
|
||||
case 'hl':
|
||||
$filter['playerCount'] = [17, 18, 19];
|
||||
break;
|
||||
case '6v6':
|
||||
$filter['playerCount'] = [11, 12, 13];
|
||||
break;
|
||||
case '4v4':
|
||||
$filter['playerCount'] = [7, 8, 9];
|
||||
break;
|
||||
}
|
||||
return $filter;
|
||||
}
|
||||
|
||||
public function listDemos() {
|
||||
$page = $this->query('page', 1);
|
||||
\Flight::json($this->demoProvider->listDemos($page, $this->getFilter()));
|
||||
}
|
||||
|
||||
public function listProfile($steamid) {
|
||||
$page = $this->query('page', 1);
|
||||
$where = $this->getFilter();
|
||||
$where['players'][] = $steamid;
|
||||
\Flight::json($this->demoProvider->listProfile($page, $where));
|
||||
}
|
||||
|
||||
public function listUploads($steamid) {
|
||||
$page = $this->query('page', 1);
|
||||
\Flight::json($this->demoProvider->listUploads($steamid, $page, $this->getFilter()));
|
||||
}
|
||||
|
||||
public function chat($demoId) {
|
||||
\Flight::json($this->demoProvider->getChat($demoId));
|
||||
}
|
||||
|
||||
public function listMaps() {
|
||||
\Flight::json($this->demoProvider->listMaps());
|
||||
}
|
||||
|
||||
public function stats() {
|
||||
\Flight::json($this->demoProvider->getStats());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue