Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Services/Eggs/EggUpdateService.php
10281 views
1
<?php
2
3
namespace Pterodactyl\Services\Eggs;
4
5
use Pterodactyl\Models\Egg;
6
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
7
use Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException;
8
9
class EggUpdateService
10
{
11
/**
12
* EggUpdateService constructor.
13
*/
14
public function __construct(protected EggRepositoryInterface $repository)
15
{
16
}
17
18
/**
19
* Update a service option.
20
*
21
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
22
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
23
* @throws NoParentConfigurationFoundException
24
*/
25
public function handle(Egg $egg, array $data): void
26
{
27
if (!is_null(array_get($data, 'config_from'))) {
28
$results = $this->repository->findCountWhere([
29
['nest_id', '=', $egg->nest_id],
30
['id', '=', array_get($data, 'config_from')],
31
]);
32
33
if ($results !== 1) {
34
throw new NoParentConfigurationFoundException(trans('exceptions.nest.egg.must_be_child'));
35
}
36
}
37
38
// TODO(dane): Once the admin UI is done being reworked and this is exposed
39
// in said UI, remove this so that you can actually update the denylist.
40
unset($data['file_denylist']);
41
42
$this->repository->withoutFreshModel()->update($egg->id, $data);
43
}
44
}
45
46