Begin updating UI

This commit is contained in:
Dane Everitt 2017-10-02 22:51:13 -05:00
parent 493c5888a3
commit ae671e6b19
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
22 changed files with 182 additions and 102 deletions

View file

@ -40,7 +40,7 @@ class InstallScriptUpdateService
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Pterodactyl\Exceptions\Service\ServiceOption\InvalidCopyFromException
*/
public function handle($option, array $data)
public function handle($option, array $data): void
{
if (! $option instanceof ServiceOption) {
$option = $this->repository->find($option);

View file

@ -9,11 +9,19 @@
namespace Pterodactyl\Services\Services\Options;
use Ramsey\Uuid\Uuid;
use Pterodactyl\Models\ServiceOption;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface;
use Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException;
class OptionCreationService
{
/**
* @var \Illuminate\Contracts\Config\Repository
*/
protected $config;
/**
* @var \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface
*/
@ -22,10 +30,12 @@ class OptionCreationService
/**
* CreationService constructor.
*
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface $repository
*/
public function __construct(ServiceOptionRepositoryInterface $repository)
public function __construct(ConfigRepository $config, ServiceOptionRepositoryInterface $repository)
{
$this->config = $config;
$this->repository = $repository;
}
@ -38,7 +48,7 @@ class OptionCreationService
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException
*/
public function handle(array $data)
public function handle(array $data): ServiceOption
{
if (! is_null(array_get($data, 'config_from'))) {
$results = $this->repository->findCountWhere([
@ -53,6 +63,14 @@ class OptionCreationService
$data['config_from'] = null;
}
return $this->repository->create($data);
if (count($parts = explode(':', array_get($data, 'tag'))) > 1) {
$data['tag'] = $this->config->get('pterodactyl.service.author') . ':' . trim(array_pop($parts));
} else {
$data['tag'] = $this->config->get('pterodactyl.service.author') . ':' . trim(array_get($data, 'tag'));
}
return $this->repository->create(array_merge($data, [
'uuid' => Uuid::uuid4()->toString(),
]), true, true);
}
}

View file

@ -9,7 +9,6 @@
namespace Pterodactyl\Services\Services\Options;
use Webmozart\Assert\Assert;
use Pterodactyl\Exceptions\Service\HasActiveServersException;
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface;
@ -50,10 +49,8 @@ class OptionDeletionService
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
* @throws \Pterodactyl\Exceptions\Service\ServiceOption\HasChildrenException
*/
public function handle($option)
public function handle(int $option): int
{
Assert::integerish($option, 'First argument passed to handle must be integer, received %s.');
$servers = $this->serverRepository->findCountWhere([['option_id', '=', $option]]);
if ($servers > 0) {
throw new HasActiveServersException(trans('exceptions.service.options.delete_has_servers'));

View file

@ -40,7 +40,7 @@ class OptionUpdateService
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException
*/
public function handle($option, array $data)
public function handle($option, array $data): void
{
if (! $option instanceof ServiceOption) {
$option = $this->repository->find($option);

View file

@ -9,6 +9,8 @@
namespace Pterodactyl\Services\Services;
use Ramsey\Uuid\Uuid;
use Pterodactyl\Models\Service;
use Pterodactyl\Traits\Services\CreatesServiceIndex;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
use Pterodactyl\Contracts\Repository\ServiceRepositoryInterface;
@ -49,16 +51,15 @@ class ServiceCreationService
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function handle(array $data)
public function handle(array $data): Service
{
return $this->repository->create(array_merge([
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'),
'folder' => array_get($data, 'folder'),
'startup' => array_get($data, 'startup'),
'index_file' => $this->getIndexScript(),
]));
], true, true);
}
}

View file

@ -47,7 +47,7 @@ class ServiceDeletionService
*
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
*/
public function handle($service)
public function handle(int $service): int
{
$count = $this->serverRepository->findCountWhere([['service_id', '=', $service]]);
if ($count > 0) {

View file

@ -36,7 +36,7 @@ class ServiceUpdateService
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function handle($service, array $data)
public function handle(int $service, array $data): void
{
if (! is_null(array_get($data, 'author'))) {
unset($data['author']);