forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEggUpdateService.php
More file actions
44 lines (37 loc) · 1.36 KB
/
EggUpdateService.php
File metadata and controls
44 lines (37 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace Pterodactyl\Services\Eggs;
use Pterodactyl\Models\Egg;
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
use Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException;
class EggUpdateService
{
/**
* EggUpdateService constructor.
*/
public function __construct(protected EggRepositoryInterface $repository)
{
}
/**
* Update a service option.
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws NoParentConfigurationFoundException
*/
public function handle(Egg $egg, array $data): void
{
if (!is_null(array_get($data, 'config_from'))) {
$results = $this->repository->findCountWhere([
['nest_id', '=', $egg->nest_id],
['id', '=', array_get($data, 'config_from')],
]);
if ($results !== 1) {
throw new NoParentConfigurationFoundException(trans('exceptions.nest.egg.must_be_child'));
}
}
// TODO(dane): Once the admin UI is done being reworked and this is exposed
// in said UI, remove this so that you can actually update the denylist.
unset($data['file_denylist']);
$this->repository->withoutFreshModel()->update($egg->id, $data);
}
}