a043071e3c
Co-authored-by: Matthew Penner <me@matthewp.io>
53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Pterodactyl\Services\Servers;
|
|
|
|
use Pterodactyl\Models\Server;
|
|
use Illuminate\Database\ConnectionInterface;
|
|
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
|
|
|
|
class ReinstallServerService
|
|
{
|
|
/**
|
|
* @var \Pterodactyl\Repositories\Wings\DaemonServerRepository
|
|
*/
|
|
private $daemonServerRepository;
|
|
|
|
/**
|
|
* @var \Illuminate\Database\ConnectionInterface
|
|
*/
|
|
private $connection;
|
|
|
|
/**
|
|
* ReinstallService constructor.
|
|
*
|
|
* @param \Illuminate\Database\ConnectionInterface $connection
|
|
* @param \Pterodactyl\Repositories\Wings\DaemonServerRepository $daemonServerRepository
|
|
*/
|
|
public function __construct(
|
|
ConnectionInterface $connection,
|
|
DaemonServerRepository $daemonServerRepository
|
|
) {
|
|
$this->daemonServerRepository = $daemonServerRepository;
|
|
$this->connection = $connection;
|
|
}
|
|
|
|
/**
|
|
* Reinstall a server on the remote daemon.
|
|
*
|
|
* @param \Pterodactyl\Models\Server $server
|
|
* @return \Pterodactyl\Models\Server
|
|
*
|
|
* @throws \Throwable
|
|
*/
|
|
public function handle(Server $server)
|
|
{
|
|
return $this->connection->transaction(function () use ($server) {
|
|
$server->forceFill(['installed' => Server::STATUS_INSTALLING])->save();
|
|
|
|
$this->daemonServerRepository->setServer($server)->reinstall();
|
|
|
|
return $server->refresh();
|
|
});
|
|
}
|
|
}
|