Forgotten changes

This commit is contained in:
Dane Everitt 2018-01-19 21:48:26 -06:00
parent a497a3d153
commit 3724559468
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 58 additions and 3 deletions

View file

@ -1 +1,56 @@
<?php
namespace Pterodactyl\Http\Controllers\Api\Application;
use Illuminate\Http\Request;
use Illuminate\Container\Container;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Extensions\Spatie\Fractalistic\Fractal;
abstract class ApplicationApiController extends Controller
{
/**
* @var \Illuminate\Http\Request
*/
private $request;
/**
* @var \Spatie\Fractalistic\Fractal
*/
protected $fractal;
/**
* ApplicationApiController constructor.
*
* @param \Pterodactyl\Extensions\Spatie\Fractalistic\Fractal $fractal
* @param \Illuminate\Http\Request $request
*/
public function __construct(Fractal $fractal, Request $request)
{
$this->fractal = $fractal;
$this->request = $request;
// Parse all of the includes to use on this request.
$includes = collect(explode(',', $request->input('include', '')))->map(function ($value) {
return trim($value);
})->filter()->toArray();
$this->fractal->parseIncludes($includes);
$this->fractal->limitRecursion(2);
}
/**
* Return an instance of an application transformer.
*
* @param string $abstract
* @return \Pterodactyl\Transformers\Api\Application\BaseTransformer
*/
public function getTransformer(string $abstract)
{
/** @var \Pterodactyl\Transformers\Api\Application\BaseTransformer $transformer */
$transformer = Container::getInstance()->make($abstract);
$transformer->setKey($this->request->attributes->get('api_key'));
return $transformer;
}
}

View file

@ -84,15 +84,15 @@ Route::group(['prefix' => '/locations'], function () {
/*
|--------------------------------------------------------------------------
| Location Controller Routes
| Server Controller Routes
|--------------------------------------------------------------------------
|
| Endpoint: /api/application/servers
|
*/
Route::group(['prefix' => '/servers'], function () {
Route::bind('location', function ($value) {
return Server::find($value) ?? new Location;
Route::bind('server', function ($value) {
return Server::find($value) ?? new Server;
});
Route::get('/', 'Servers\ServerController@index')->name('api.application.servers');