2017-10-06 04:09:43 +00:00
|
|
|
<?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
|
|
|
|
*/
|
|
|
|
|
2017-10-07 21:16:51 +00:00
|
|
|
namespace Pterodactyl\Services\Eggs;
|
2017-10-06 04:09:43 +00:00
|
|
|
|
2017-10-07 04:57:53 +00:00
|
|
|
use Pterodactyl\Models\Egg;
|
|
|
|
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
2017-10-06 04:09:43 +00:00
|
|
|
|
2017-10-07 21:16:51 +00:00
|
|
|
class EggConfigurationService
|
2017-10-06 04:09:43 +00:00
|
|
|
{
|
2017-10-07 21:16:51 +00:00
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
|
|
|
|
*/
|
2017-10-06 04:09:43 +00:00
|
|
|
protected $repository;
|
|
|
|
|
|
|
|
/**
|
2017-10-07 21:16:51 +00:00
|
|
|
* EggConfigurationService constructor.
|
2017-10-06 04:09:43 +00:00
|
|
|
*
|
2017-10-07 04:57:53 +00:00
|
|
|
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
|
2017-10-06 04:09:43 +00:00
|
|
|
*/
|
2017-10-07 04:57:53 +00:00
|
|
|
public function __construct(EggRepositoryInterface $repository)
|
2017-10-06 04:09:43 +00:00
|
|
|
{
|
|
|
|
$this->repository = $repository;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-10-07 21:16:51 +00:00
|
|
|
* Return an Egg file to be used by the Daemon.
|
2017-10-06 04:09:43 +00:00
|
|
|
*
|
2017-10-07 04:57:53 +00:00
|
|
|
* @param int|\Pterodactyl\Models\Egg $option
|
2017-10-06 04:09:43 +00:00
|
|
|
* @return array
|
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
|
|
*/
|
|
|
|
public function handle($option): array
|
|
|
|
{
|
2017-10-07 04:57:53 +00:00
|
|
|
if (! $option instanceof Egg) {
|
2017-10-06 04:09:43 +00:00
|
|
|
$option = $this->repository->getWithCopyAttributes($option);
|
|
|
|
}
|
|
|
|
|
|
|
|
return [
|
|
|
|
'startup' => json_decode($option->inherit_config_startup),
|
|
|
|
'stop' => $option->inherit_config_stop,
|
|
|
|
'configs' => json_decode($option->inherit_config_files),
|
|
|
|
'log' => json_decode($option->inherit_config_logs),
|
|
|
|
'query' => 'none',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|