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

expose backend and path trough api

This commit is contained in:
Robin Appelman 2017-07-15 21:46:52 +02:00
commit b588c8ce7e
5 changed files with 40 additions and 8 deletions

View file

@ -38,6 +38,10 @@ class Demo implements \JsonSerializable {
private $players; private $players;
/** @var string */ /** @var string */
private $hash; private $hash;
/** @var string */
private $backend;
/** @var string */
private $path;
public function __construct( public function __construct(
int $id, int $id,
@ -54,7 +58,9 @@ class Demo implements \JsonSerializable {
int $blueScore, int $blueScore,
int $playerCount, int $playerCount,
int $uploader, int $uploader,
string $hash string $hash,
string $backend,
string $path
) { ) {
$this->id = $id; $this->id = $id;
$this->url = $url; $this->url = $url;
@ -71,6 +77,8 @@ class Demo implements \JsonSerializable {
$this->playerCount = $playerCount; $this->playerCount = $playerCount;
$this->uploader = $uploader; $this->uploader = $uploader;
$this->hash = $hash; $this->hash = $hash;
$this->backend = $backend;
$this->path = $path;
} }
public function getId(): int { public function getId(): int {
@ -153,7 +161,9 @@ class Demo implements \JsonSerializable {
(int)$row['scoreBlue'], (int)$row['scoreBlue'],
(int)$row['playerCount'], (int)$row['playerCount'],
(int)$row['uploader'], (int)$row['uploader'],
$row['hash'] $row['hash'],
$row['backend'],
$row['path']
); );
} }
@ -172,6 +182,14 @@ class Demo implements \JsonSerializable {
return $this->hash; return $this->hash;
} }
public function getBackend(): string {
return $this->backend;
}
public function getPath(): string {
return $this->path;
}
public function jsonSerialize() { public function jsonSerialize() {
$data = [ $data = [
'id' => $this->getId(), 'id' => $this->getId(),
@ -188,7 +206,9 @@ class Demo implements \JsonSerializable {
'blueScore' => $this->getBlueScore(), 'blueScore' => $this->getBlueScore(),
'playerCount' => $this->getPlayerCount(), 'playerCount' => $this->getPlayerCount(),
'uploader' => $this->uploaderUser ? $this->getUploaderUser()->jsonSerialize() : $this->getUploader(), 'uploader' => $this->uploaderUser ? $this->getUploaderUser()->jsonSerialize() : $this->getUploader(),
'hash' => $this->getHash() 'hash' => $this->getHash(),
'backend' => $this->getBackend(),
'path' => $this->getPath()
]; ];
if ($this->players) { if ($this->players) {
$data['players'] = $this->getPlayers(); $data['players'] = $this->getPlayers();

View file

@ -52,7 +52,9 @@ class DemoSaver {
$demo->getBlueScore(), $demo->getBlueScore(),
count($demo->getPlayers()), count($demo->getPlayers()),
$upload->getUploaderId(), $upload->getUploaderId(),
$upload->getHash() $upload->getHash(),
$storedDemo->getBackend(),
$storedDemo->getPath()
), $storedDemo->getBackend(), $storedDemo->getPath()); ), $storedDemo->getBackend(), $storedDemo->getPath());
foreach ($demo->getPlayers() as $player) { foreach ($demo->getPlayers() as $player) {

View file

@ -45,7 +45,9 @@ class DemoListProviderTest extends TestCase {
2, 2,
$playerCount, $playerCount,
$uploaderId, $uploaderId,
'hash' 'hash',
'backend',
'path'
); );
} }

View file

@ -59,7 +59,9 @@ class DemoProviderTest extends TestCase {
2, 2,
18, 18,
$uploader->getId(), $uploader->getId(),
'hash' 'hash',
'dummy',
'path'
); );
$demo->setUploaderUser($uploader); $demo->setUploaderUser($uploader);
@ -112,7 +114,11 @@ class DemoProviderTest extends TestCase {
2, 2,
18, 18,
$uploader->getId(), $uploader->getId(),
'hash' 'hash',
'backend',
'path',
'dummy',
'path'
); );
$id = $this->provider->storeDemo($demo, 'dummy', 'path'); $id = $this->provider->storeDemo($demo, 'dummy', 'path');

View file

@ -238,7 +238,9 @@ class UploadProviderTest extends TestCase {
2, 2,
2, 2,
1, 1,
$hash $hash,
'b',
'p'
), ),
'test', 'test' 'test', 'test'
); );