Path: blob/1.0-develop/app/Transformers/Api/Client/BaseClientTransformer.php
10284 views
<?php12namespace Pterodactyl\Transformers\Api\Client;34use Pterodactyl\Models\User;5use Webmozart\Assert\Assert;6use Pterodactyl\Models\Server;7use Pterodactyl\Transformers\Api\Application\BaseTransformer as BaseApplicationTransformer;89abstract class BaseClientTransformer extends BaseApplicationTransformer10{11/**12* Return the user model of the user requesting this transformation.13*/14public function getUser(): User15{16return $this->request->user();17}1819/**20* Determine if the API key loaded onto the transformer has permission21* to access a different resource. This is used when including other22* models on a transformation request.23*24* @noinspection PhpParameterNameChangedDuringInheritanceInspection25*/26protected function authorize(string $ability, ?Server $server = null): bool27{28Assert::isInstanceOf($server, Server::class);2930return $this->request->user()->can($ability, [$server]);31}3233protected function makeTransformer(string $abstract)34{35Assert::subclassOf($abstract, self::class);3637return parent::makeTransformer($abstract);38}39}404142