Update ServerInstallController.php
This commit is contained in:
parent
4192bcab4b
commit
397df3bf71
1 changed files with 14 additions and 1 deletions
|
@ -9,6 +9,8 @@ use Illuminate\Http\JsonResponse;
|
|||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
||||
use Pterodactyl\Http\Requests\Api\Remote\InstallationDataRequest;
|
||||
use Pterodactyl\Events\Server\Installed as ServerInstalled;
|
||||
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
|
||||
|
||||
class ServerInstallController extends Controller
|
||||
{
|
||||
|
@ -17,12 +19,18 @@ class ServerInstallController extends Controller
|
|||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Events\Dispatcher
|
||||
*/
|
||||
private $eventDispatcher;
|
||||
|
||||
/**
|
||||
* ServerInstallController constructor.
|
||||
*/
|
||||
public function __construct(ServerRepository $repository)
|
||||
public function __construct(ServerRepository $repository, EventDispatcher $eventDispatcher)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,6 +71,11 @@ class ServerInstallController extends Controller
|
|||
|
||||
$this->repository->update($server->id, ['status' => $status], true, true);
|
||||
|
||||
// If the server successfully installed, fire installed event.
|
||||
if ($status === null) {
|
||||
$this->eventDispatcher->dispatch(new ServerInstalled($server));
|
||||
}
|
||||
|
||||
return new JsonResponse([], Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue