Skip to content

Commit 3724559

Browse files
committed
Forgotten changes
1 parent a497a3d commit 3724559

File tree

2 files changed

+58
-3
lines changed

2 files changed

+58
-3
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,56 @@
11
<?php
2+
3+
namespace Pterodactyl\Http\Controllers\Api\Application;
4+
5+
use Illuminate\Http\Request;
6+
use Illuminate\Container\Container;
7+
use Pterodactyl\Http\Controllers\Controller;
8+
use Pterodactyl\Extensions\Spatie\Fractalistic\Fractal;
9+
10+
abstract class ApplicationApiController extends Controller
11+
{
12+
/**
13+
* @var \Illuminate\Http\Request
14+
*/
15+
private $request;
16+
17+
/**
18+
* @var \Spatie\Fractalistic\Fractal
19+
*/
20+
protected $fractal;
21+
22+
/**
23+
* ApplicationApiController constructor.
24+
*
25+
* @param \Pterodactyl\Extensions\Spatie\Fractalistic\Fractal $fractal
26+
* @param \Illuminate\Http\Request $request
27+
*/
28+
public function __construct(Fractal $fractal, Request $request)
29+
{
30+
$this->fractal = $fractal;
31+
$this->request = $request;
32+
33+
// Parse all of the includes to use on this request.
34+
$includes = collect(explode(',', $request->input('include', '')))->map(function ($value) {
35+
return trim($value);
36+
})->filter()->toArray();
37+
38+
$this->fractal->parseIncludes($includes);
39+
$this->fractal->limitRecursion(2);
40+
}
41+
42+
/**
43+
* Return an instance of an application transformer.
44+
*
45+
* @param string $abstract
46+
* @return \Pterodactyl\Transformers\Api\Application\BaseTransformer
47+
*/
48+
public function getTransformer(string $abstract)
49+
{
50+
/** @var \Pterodactyl\Transformers\Api\Application\BaseTransformer $transformer */
51+
$transformer = Container::getInstance()->make($abstract);
52+
$transformer->setKey($this->request->attributes->get('api_key'));
53+
54+
return $transformer;
55+
}
56+
}

routes/api-application.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@
8484

8585
/*
8686
|--------------------------------------------------------------------------
87-
| Location Controller Routes
87+
| Server Controller Routes
8888
|--------------------------------------------------------------------------
8989
|
9090
| Endpoint: /api/application/servers
9191
|
9292
*/
9393
Route::group(['prefix' => '/servers'], function () {
94-
Route::bind('location', function ($value) {
95-
return Server::find($value) ?? new Location;
94+
Route::bind('server', function ($value) {
95+
return Server::find($value) ?? new Server;
9696
});
9797

9898
Route::get('/', 'Servers\ServerController@index')->name('api.application.servers');

0 commit comments

Comments
 (0)