misc_pterodactyl-panel/app/Services/Servers/ContainerRebuildService.php

43 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace Pterodactyl\Services\Servers;
2017-08-05 22:26:30 +00:00
use Pterodactyl\Models\Server;
use GuzzleHttp\Exception\RequestException;
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface;
class ContainerRebuildService
{
/**
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
*/
private $repository;
/**
* ContainerRebuildService constructor.
*
* @param \Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface $repository
*/
public function __construct(ServerRepositoryInterface $repository)
{
$this->repository = $repository;
}
/**
* Mark a server for rebuild on next boot cycle.
*
* @param \Pterodactyl\Models\Server $server
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
public function handle(Server $server)
{
try {
$this->repository->setServer($server)->rebuild();
} catch (RequestException $exception) {
throw new DaemonConnectionException($exception);
}
}
}