Skip to content

Commit cdfbc60

Browse files
committed
Push pack services and fix for failing tests
1 parent 280633b commit cdfbc60

File tree

21 files changed

+415
-378
lines changed

21 files changed

+415
-378
lines changed

app/Contracts/Repository/PackRepositoryInterface.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,32 @@
2828

2929
interface PackRepositoryInterface extends RepositoryInterface, SearchableInterface
3030
{
31+
/**
32+
* Return a paginated listing of packs with their associated option and server count.
33+
*
34+
* @param int $paginate
35+
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
36+
*/
37+
public function paginateWithOptionAndServerCount($paginate = 50);
38+
39+
/**
40+
* Return a pack with the associated server models attached to it.
41+
*
42+
* @param int $id
43+
* @return \Illuminate\Database\Eloquent\Collection
44+
*
45+
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
46+
*/
47+
public function getWithServers($id);
48+
3149
/**
3250
* Return all of the file archives for a given pack.
3351
*
3452
* @param int $id
3553
* @param bool $collection
3654
* @return object|\Illuminate\Support\Collection
55+
*
56+
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
3757
*/
3858
public function getFileArchives($id, $collection = false);
3959
}

app/Exceptions/Service/HasActiveServersException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424

2525
namespace Pterodactyl\Exceptions\Service;
2626

27-
class HasActiveServersException extends \Exception
27+
use Pterodactyl\Exceptions\DisplayException;
28+
29+
class HasActiveServersException extends DisplayException
2830
{
2931
//
3032
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/*
3+
* Pterodactyl - Panel
4+
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
namespace Pterodactyl\Exceptions\Service\Pack;
26+
27+
class ZipArchiveCreationException extends \Exception
28+
{
29+
//
30+
}

app/Http/Controllers/Admin/NodesController.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ public function store(NodeFormRequest $request)
174174
*
175175
* @param int $node
176176
* @return \Illuminate\View\View
177+
*
178+
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
177179
*/
178180
public function viewIndex($node)
179181
{
@@ -213,6 +215,8 @@ public function viewConfiguration(Node $node)
213215
*
214216
* @param int $node
215217
* @return \Illuminate\View\View
218+
*
219+
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
216220
*/
217221
public function viewAllocation($node)
218222
{
@@ -227,6 +231,8 @@ public function viewAllocation($node)
227231
*
228232
* @param int $node
229233
* @return \Illuminate\View\View
234+
*
235+
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
230236
*/
231237
public function viewServers($node)
232238
{
@@ -299,9 +305,10 @@ public function allocationRemoveBlock(Request $request, $node)
299305
* Sets an alias for a specific allocation on a node.
300306
*
301307
* @param \Pterodactyl\Http\Requests\Admin\Node\AllocationAliasFormRequest $request
302-
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
308+
* @return \Symfony\Component\HttpFoundation\Response
303309
*
304310
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
311+
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
305312
*/
306313
public function allocationSetAlias(AllocationAliasFormRequest $request)
307314
{

app/Http/Controllers/Admin/OptionController.php

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
use Pterodactyl\Models\ServiceOption;
3131
use Pterodactyl\Http\Controllers\Controller;
3232
use Pterodactyl\Http\Requests\Admin\Service\EditOptionScript;
33-
use Pterodactyl\Exceptions\Service\HasActiveServersException;
3433
use Pterodactyl\Services\Services\Options\OptionUpdateService;
3534
use Pterodactyl\Contracts\Repository\ServiceRepositoryInterface;
3635
use Pterodactyl\Services\Services\Options\OptionCreationService;
@@ -81,13 +80,13 @@ class OptionController extends Controller
8180
/**
8281
* OptionController constructor.
8382
*
84-
* @param \Prologue\Alerts\AlertsMessageBag $alert
85-
* @param \Pterodactyl\Services\Services\Options\InstallScriptUpdateService $installScriptUpdateService
86-
* @param \Pterodactyl\Services\Services\Options\OptionCreationService $optionCreationService
87-
* @param \Pterodactyl\Services\Services\Options\OptionDeletionService $optionDeletionService
88-
* @param \Pterodactyl\Services\Services\Options\OptionUpdateService $optionUpdateService
89-
* @param \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface $serviceRepository
90-
* @param \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface $serviceOptionRepository
83+
* @param \Prologue\Alerts\AlertsMessageBag $alert
84+
* @param \Pterodactyl\Services\Services\Options\InstallScriptUpdateService $installScriptUpdateService
85+
* @param \Pterodactyl\Services\Services\Options\OptionCreationService $optionCreationService
86+
* @param \Pterodactyl\Services\Services\Options\OptionDeletionService $optionDeletionService
87+
* @param \Pterodactyl\Services\Services\Options\OptionUpdateService $optionUpdateService
88+
* @param \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface $serviceRepository
89+
* @param \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface $serviceOptionRepository
9190
*/
9291
public function __construct(
9392
AlertsMessageBag $alert,
@@ -147,17 +146,13 @@ public function store(ServiceOptionFormRequest $request)
147146
*
148147
* @param \Pterodactyl\Models\ServiceOption $option
149148
* @return \Illuminate\Http\RedirectResponse
149+
*
150+
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
150151
*/
151152
public function destroy(ServiceOption $option)
152153
{
153-
try {
154-
$this->optionDeletionService->handle($option->id);
155-
$this->alert->success(trans('admin/services.options.notices.option_deleted'))->flash();
156-
} catch (HasActiveServersException $exception) {
157-
$this->alert->danger($exception->getMessage())->flash();
158-
159-
return redirect()->route('admin.services.option.view', $option->id);
160-
}
154+
$this->optionDeletionService->handle($option->id);
155+
$this->alert->success(trans('admin/services.options.notices.option_deleted'))->flash();
161156

162157
return redirect()->route('admin.services.view', $option->service_id);
163158
}

0 commit comments

Comments
 (0)