Path: blob/1.0-develop/app/Transformers/Api/Client/EggVariableTransformer.php
10284 views
<?php12namespace Pterodactyl\Transformers\Api\Client;34use Pterodactyl\Models\EggVariable;56class EggVariableTransformer extends BaseClientTransformer7{8public function getResourceName(): string9{10return EggVariable::RESOURCE_NAME;11}1213public function transform(EggVariable $variable): array14{15// This guards against someone incorrectly retrieving variables (haha, me) and then passing16// them into the transformer and along to the user. Just throw an exception and break the entire17// pathway since you should never be exposing these types of variables to a client.18if (!$variable->user_viewable) {19throw new \BadMethodCallException('Cannot transform a hidden egg variable in a client transformer.');20}2122return [23'name' => $variable->name,24'description' => $variable->description,25'env_variable' => $variable->env_variable,26'default_value' => $variable->default_value,27'server_value' => $variable->server_value,28'is_editable' => $variable->user_editable,29'rules' => $variable->rules,30];31}32}333435