|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Gameap\Http\Responses\GdaemonAPI; |
|
4
|
|
|
|
|
5
|
|
|
class GameModResponse implements \JsonSerializable |
|
6
|
|
|
{ |
|
7
|
|
|
/** @var \Gameap\Models\GameMod */ |
|
8
|
|
|
private $gameMod; |
|
9
|
|
|
|
|
10
|
|
|
/** @var string */ |
|
11
|
|
|
private $os; |
|
12
|
|
|
|
|
13
|
|
|
public function __construct(\Gameap\Models\GameMod $gameMod, string $os = 'linux') |
|
14
|
|
|
{ |
|
15
|
|
|
$this->gameMod = $gameMod; |
|
16
|
|
|
$this->os = $os; |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
public function jsonSerialize() |
|
20
|
|
|
{ |
|
21
|
|
|
$remoteRepository = ''; |
|
22
|
|
|
$localRepository = ''; |
|
23
|
|
|
$defaultStartCmd = ''; |
|
24
|
|
|
if ($this->os === 'linux') { |
|
25
|
|
|
$remoteRepository = $this->gameMod->remote_repository_linux; |
|
26
|
|
|
$localRepository = $this->gameMod->local_repository_linux; |
|
27
|
|
|
$defaultStartCmd = $this->gameMod->start_cmd_linux; |
|
28
|
|
|
} elseif ($this->os === 'windows') { |
|
29
|
|
|
$remoteRepository = $this->gameMod->remote_repository_windows; |
|
30
|
|
|
$localRepository = $this->gameMod->local_repository_windows; |
|
31
|
|
|
$defaultStartCmd = $this->gameMod->start_cmd_windows; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
return [ |
|
35
|
|
|
'id' => $this->gameMod->id, |
|
36
|
|
|
'game_code' => $this->gameMod->game_code, |
|
37
|
|
|
'name' => $this->gameMod->name, |
|
38
|
|
|
'vars' => $this->gameMod->vars, |
|
39
|
|
|
'remote_repository' => $remoteRepository, |
|
40
|
|
|
'local_repository' => $localRepository, |
|
41
|
|
|
'default_start_cmd' => $defaultStartCmd, |
|
42
|
|
|
'default_start_cmd_linux' => $this->gameMod->start_cmd_linux, |
|
43
|
|
|
'default_start_cmd_windows' => $this->gameMod->start_cmd_windows, |
|
44
|
|
|
]; |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
|