This breaks literally the entire panel.
This commit is contained in:
parent
344c1a9885
commit
df87ea0867
88 changed files with 1205 additions and 992 deletions
60
app/Services/Nests/NestCreationService.php
Normal file
60
app/Services/Nests/NestCreationService.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Services\Nests;
|
||||
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Pterodactyl\Models\Nest;
|
||||
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
|
||||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
||||
|
||||
class NestCreationService
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Config\Repository
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* NestCreationService constructor.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Config\Repository $config
|
||||
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository
|
||||
*/
|
||||
public function __construct(
|
||||
ConfigRepository $config,
|
||||
NestRepositoryInterface $repository
|
||||
) {
|
||||
$this->config = $config;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new nest on the system.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Pterodactyl\Models\Nest
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
public function handle(array $data): Nest
|
||||
{
|
||||
return $this->repository->create([
|
||||
'uuid' => Uuid::uuid4()->toString(),
|
||||
'author' => $this->config->get('pterodactyl.service.author'),
|
||||
'name' => array_get($data, 'name'),
|
||||
'description' => array_get($data, 'description'),
|
||||
], true, true);
|
||||
}
|
||||
}
|
59
app/Services/Nests/NestDeletionService.php
Normal file
59
app/Services/Nests/NestDeletionService.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Services\Nests;
|
||||
|
||||
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Service\HasActiveServersException;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
|
||||
class NestDeletionService
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
|
||||
*/
|
||||
protected $serverRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* NestDeletionService constructor.
|
||||
*
|
||||
* @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $serverRepository
|
||||
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository
|
||||
*/
|
||||
public function __construct(
|
||||
ServerRepositoryInterface $serverRepository,
|
||||
NestRepositoryInterface $repository
|
||||
) {
|
||||
$this->serverRepository = $serverRepository;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a nest from the system only if there are no servers attached to it.
|
||||
*
|
||||
* @param int $nest
|
||||
* @return int
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
|
||||
*/
|
||||
public function handle(int $nest): int
|
||||
{
|
||||
$count = $this->serverRepository->findCountWhere([['nest_id', '=', $nest]]);
|
||||
if ($count > 0) {
|
||||
throw new HasActiveServersException(trans('exceptions.service.delete_has_servers'));
|
||||
}
|
||||
|
||||
return $this->repository->delete($nest);
|
||||
}
|
||||
}
|
47
app/Services/Nests/NestUpdateService.php
Normal file
47
app/Services/Nests/NestUpdateService.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Services\Nests;
|
||||
|
||||
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
|
||||
|
||||
class NestUpdateService
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* NestUpdateService constructor.
|
||||
*
|
||||
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository
|
||||
*/
|
||||
public function __construct(NestRepositoryInterface $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a nest and prevent changing the author once it is set.
|
||||
*
|
||||
* @param int $nest
|
||||
* @param array $data
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function handle(int $nest, array $data)
|
||||
{
|
||||
if (! is_null(array_get($data, 'author'))) {
|
||||
unset($data['author']);
|
||||
}
|
||||
|
||||
$this->repository->withoutFresh()->update($nest, $data);
|
||||
}
|
||||
}
|
Reference in a new issue