Skip to content

Commit 6e05cd7

Browse files
committed
Adding steam to setup command
1 parent 166787e commit 6e05cd7

File tree

1 file changed

+88
-13
lines changed

1 file changed

+88
-13
lines changed

src/commands/Syntax/SetupCommand.php

Lines changed: 88 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,7 @@ class SetupCommand extends Command {
2626
*
2727
* @var string[]
2828
*/
29-
protected $packages = ['chat', 'forum'];
30-
31-
/**
32-
* An array of packages that will need a config loaded
33-
*
34-
* @var string[]
35-
*/
36-
protected $packagesWithConfig = ['chat'];
29+
protected $packages = ['chat', 'forum', 'steam-api'];
3730

3831
/**
3932
* An object containing the core config details
@@ -56,6 +49,20 @@ class SetupCommand extends Command {
5649
*/
5750
protected $chatConfig;
5851

52+
/**
53+
* An object containing the forum config details
54+
*
55+
* @var string[]
56+
*/
57+
protected $forumDetails;
58+
59+
/**
60+
* An object containing the steam config details
61+
*
62+
* @var string[]
63+
*/
64+
protected $steamDetails;
65+
5966
/**
6067
* The output stream for any artisan commands
6168
*
@@ -72,9 +79,11 @@ public function __construct()
7279
{
7380
parent::__construct();
7481

75-
$this->coreDetails = new stdClass();
76-
$this->chatDetails = new stdClass();
77-
$this->stream = fopen('php://output', 'w');
82+
$this->coreDetails = new stdClass();
83+
$this->chatDetails = new stdClass();
84+
$this->forumDetails = new stdClass();
85+
$this->steamDetails = new stdClass();
86+
$this->stream = fopen('php://output', 'w');
7887
}
7988

8089
/**
@@ -119,6 +128,22 @@ protected function confirmConfig($type)
119128
return $this->configureChat();
120129
}
121130
break;
131+
case 'forum':
132+
$this->line($this->forumDetails ."\n");
133+
if (!$this->confirm('Do you want to keep this configuration? [yes|no]')) {
134+
return $this->setUpForum();
135+
} else {
136+
return $this->configureForum();
137+
}
138+
break;
139+
case 'steam':
140+
$this->line($this->steamDetails ."\n");
141+
if (!$this->confirm('Do you want to keep this configuration? [yes|no]')) {
142+
return $this->setUpSteam();
143+
} else {
144+
return $this->configureSteam();
145+
}
146+
break;
122147
}
123148
}
124149

@@ -156,13 +181,19 @@ protected function setUpSyntax($package)
156181
case 'chat':
157182
return $this->setUpChat();
158183
break;
184+
case 'forum':
185+
return $this->setUpForum();
186+
break;
187+
case 'steam-api':
188+
return $this->setUpSteam();
189+
break;
159190
}
160191
}
161192

162193
protected function setUpCore()
163194
{
164195
// Set up our syntax config
165-
$this->comment('Setting up syntax details...');
196+
$this->comment('Setting up core details...');
166197
$this->coreDetails->controlRoomDetail = $this->ask('What is this site\'s control room name?');
167198
$this->coreDetails->siteName = $this->ask('What is this name to display for this site?');
168199
$this->coreDetails->siteIcon = $this->ask('What is this icon to display for this site? (Use tha last part of the font-awesome icon class)');
@@ -174,7 +205,7 @@ protected function setUpCore()
174205
protected function setUpChat()
175206
{
176207
// Set up our syntax config
177-
$this->comment('Setting up syntax details...');
208+
$this->comment('Setting up chat details...');
178209
$this->chatDetails->debug = $this->confirm('Should the chats show debug info? [Hit enter to leave as true]', true) ? true : false;
179210
$this->chatDetails->port = $this->ask('What is the chat port? [Hit enter to leave as 1337]', 1337);
180211
$this->chatDetails->backLog = $this->ask('How much back log should the chats get? [Hit enter to leave as 100]', 100);
@@ -187,6 +218,28 @@ protected function setUpChat()
187218
$this->confirmConfig('chat');
188219
}
189220

221+
protected function setUpForum()
222+
{
223+
// Set up our syntax config
224+
$this->comment('Setting up forum details...');
225+
$this->forumDetails->forumNews = $this->confirm('Will this site use forum posts on the front page? [Hit enter to leave as true]', true) ? true : false;
226+
227+
$this->confirmConfig('forum');
228+
}
229+
230+
protected function setUpSteam()
231+
{
232+
// Set up our syntax config
233+
$this->comment('Setting up steam api details...');
234+
$this->steamDetails->steamApiKey = $this->ask('What is your steam api key?');
235+
236+
while ($this->steamDetails->steamApiKey == null) {
237+
$this->steamDetails->steamApiKey = $this->ask('This cannot be empty. What is your steam api key?');
238+
}
239+
240+
$this->confirmConfig('steam');
241+
}
242+
190243
/********************************************************************
191244
* Configuration Methods
192245
*******************************************************************/
@@ -208,6 +261,28 @@ protected function configureChat()
208261
File::put($path, $this->chatConfig);
209262
}
210263

264+
protected function configureForum()
265+
{
266+
list($path, $contents) = $this->getConfig('packages/syntax/forum/config.php');
267+
268+
foreach ($this->forumDetails as $key => $value) {
269+
$contents = str_replace($this->laravel['config']['forum::'. $key], $value, $contents);
270+
}
271+
272+
File::put($path, $contents);
273+
}
274+
275+
protected function configureSteam()
276+
{
277+
list($path, $contents) = $this->getConfig('packages/syntax/steam-api/config.php');
278+
279+
foreach ($this->steamDetails as $key => $value) {
280+
$contents = str_replace($this->laravel['config']['steam-api::'. $key], $value, $contents);
281+
}
282+
283+
File::put($path, $contents);
284+
}
285+
211286
/********************************************************************
212287
* Extra Methods
213288
*******************************************************************/

0 commit comments

Comments
 (0)