Correctly set the resource name on empty transformers
This commit is contained in:
parent
1bc1b87422
commit
3d14974d64
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
namespace Pterodactyl\Extensions\Spatie\Fractalistic;
|
namespace Pterodactyl\Extensions\Spatie\Fractalistic;
|
||||||
|
|
||||||
use League\Fractal\TransformerAbstract;
|
|
||||||
use Spatie\Fractal\Fractal as SpatieFractal;
|
use Spatie\Fractal\Fractal as SpatieFractal;
|
||||||
|
use Pterodactyl\Transformers\Api\Transformer;
|
||||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
use Pterodactyl\Extensions\League\Fractal\Serializers\PterodactylSerializer;
|
use Pterodactyl\Extensions\League\Fractal\Serializers\PterodactylSerializer;
|
||||||
|
@ -33,12 +33,9 @@ class Fractal extends SpatieFractal
|
||||||
|
|
||||||
// If the resource name is not set attempt to pull it off the transformer
|
// If the resource name is not set attempt to pull it off the transformer
|
||||||
// itself and set it automatically.
|
// itself and set it automatically.
|
||||||
if (
|
$class = is_string($this->transformer) ? new $this->transformer : $this->transformer;
|
||||||
is_null($this->resourceName)
|
if (is_null($this->resourceName) && $class instanceof Transformer) {
|
||||||
&& $this->transformer instanceof TransformerAbstract
|
$this->resourceName = $class->getResourceName();
|
||||||
&& method_exists($this->transformer, 'getResourceName')
|
|
||||||
) {
|
|
||||||
$this->resourceName = $this->transformer->getResourceName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::createData();
|
return parent::createData();
|
||||||
|
|
Loading…
Reference in New Issue