Update doc blocks for all app/

This commit is contained in:
Dane Everitt 2017-03-19 19:36:50 -04:00
parent 5e27772fef
commit 0312c974f5
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
114 changed files with 1360 additions and 949 deletions

View file

@ -37,6 +37,7 @@ class APIRepository
{
/**
* Valid API permissions.
*
* @var array
*/
protected $permissions = [
@ -89,14 +90,23 @@ class APIRepository
/**
* Holder for listing of allowed IPs when creating a new key.
*
* @var array
*/
protected $allowed = [];
/**
* The eloquent model for a user.
*
* @var \Pterodactyl\Models\User
*/
protected $user;
/**
* Constructor.
* Constructor for API Repository.
*
* @param null|\Pterodactyl\Models\User $user
* @return void
*/
public function __construct(Models\User $user = null)
{
@ -109,12 +119,11 @@ class APIRepository
/**
* Create a New API Keypair on the system.
*
* @param array $data An array with a permissions and allowed_ips key.
* @param array $data
* @return string
*
* @throws Pterodactyl\Exceptions\DisplayException if there was an error that can be safely displayed to end-users.
* @throws Pterodactyl\Exceptions\DisplayValidationException if there was a validation error.
*
* @return string Returns the generated secret token.
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function create(array $data)
{
@ -213,11 +222,10 @@ class APIRepository
/**
* Revokes an API key and associated permissions.
*
* @param string $key The public key.
*
* @throws Illuminate\Database\Eloquent\ModelNotFoundException
*
* @param string $key
* @return void
*
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
*/
public function revoke($key)
{

View file

@ -30,19 +30,32 @@ use Pterodactyl\Exceptions\DisplayException;
class CommandRepository
{
/**
* The Eloquent Model associated with the requested server.
*
* @var \Pterodactyl\Models\Server
*/
protected $server;
/**
* Constuctor for repository.
*
* @param int|\Pterodactyl\Models\Server $server
* @return void
*/
public function __construct($server)
{
$this->server = ($server instanceof Models\Server) ? $server : Models\Server::findOrFail($server);
}
/**
* [send description].
* @param string $command
* @return bool
* @throws DisplayException
* @throws RequestException
* Sends a command to the daemon.
*
* @param string $command
* @return string
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \GuzzleHttp\Exception\RequestException
*/
public function send($command)
{

View file

@ -35,14 +35,15 @@ class FileRepository
/**
* The Eloquent Model associated with the requested server.
*
* @var \Illuminate\Database\Eloquent\Model
* @var \Pterodactyl\Models\Server
*/
protected $server;
/**
* Constructor.
*
* @param string $server The server Short UUID
* @param string $uuid
* @return void
*/
public function __construct($uuid)
{
@ -52,8 +53,11 @@ class FileRepository
/**
* Get the contents of a requested file for the server.
*
* @param string $file
* @param string $file
* @return array
*
* @throws \GuzzleHttp\Exception\RequestException
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function returnFileContents($file)
{
@ -95,9 +99,12 @@ class FileRepository
/**
* Save the contents of a requested file on the daemon.
*
* @param string $file
* @param string $content
* @param string $file
* @param string $content
* @return bool
*
* @throws \GuzzleHttp\Exception\RequestException
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function saveFileContents($file, $content)
{
@ -125,8 +132,11 @@ class FileRepository
/**
* Returns a listing of all files and folders within a specified directory on the daemon.
*
* @param string $directory
* @param string $directory
* @return object
*
* @throws \GuzzleHttp\Exception\RequestException
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function returnDirectoryListing($directory)
{

View file

@ -29,13 +29,33 @@ use Pterodactyl\Exceptions\DisplayException;
class PowerRepository
{
/**
* The Eloquent Model associated with the requested server.
*
* @var \Pterodactyl\Models\Server
*/
protected $server;
/**
* Constuctor for repository.
*
* @param int|\Pterodactyl\Models\Server $server
* @return void
*/
public function __construct($server)
{
$this->server = ($server instanceof Models\Server) ? $server : Models\Server::findOrFail($server);
}
/**
* Sends a power option to the daemon.
*
* @param string $action
* @return string
*
* @throws \GuzzleHttp\Exception\RequestException
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function do($action)
{
// We don't use the user's specific daemon secret here since we
@ -58,21 +78,41 @@ class PowerRepository
}
}
/**
* Starts a server.
*
* @return void
*/
public function start()
{
$this->do('start');
}
/**
* Stops a server.
*
* @return void
*/
public function stop()
{
$this->do('stop');
}
/**
* Restarts a server.
*
* @return void
*/
public function restart()
{
$this->do('restart');
}
/**
* Kills a server.
*
* @return void
*/
public function kill()
{
$this->do('kill');

View file

@ -39,8 +39,8 @@ class DatabaseRepository
/**
* Adds a new database to a specified database host server.
*
* @param int $id
* @param array $data
* @param int $id
* @param array $data
* @return \Pterodactyl\Models\Database
*
* @throws \Pterodactyl\Exceptions\DisplayException
@ -128,8 +128,8 @@ class DatabaseRepository
/**
* Updates the password for a given database.
*
* @param int $id
* @param string $password
* @param int $id
* @param string $password
* @return void
*
* @todo Fix logic behind resetting passwords.
@ -174,7 +174,7 @@ class DatabaseRepository
/**
* Drops a database from the associated database host.
*
* @param int $id
* @param int $id
* @return void
*/
public function drop($id)
@ -204,7 +204,7 @@ class DatabaseRepository
/**
* Deletes a database host from the system if it has no associated databases.
*
* @param int $server
* @param int $id
* @return void
*
* @throws \Pterodactyl\Exceptions\DisplayException
@ -223,7 +223,7 @@ class DatabaseRepository
/**
* Adds a new Database Host to the system.
*
* @param array $data
* @param array $data
* @return \Pterodactyl\Models\DatabaseHost
*
* @throws \Pterodactyl\Exceptions\DisplayValidationException
@ -281,8 +281,8 @@ class DatabaseRepository
/**
* Updates a Database Host on the system.
*
* @param int $id
* @param array $data
* @param int $id
* @param array $data
* @return \Pterodactyl\Models\DatabaseHost
*
* @throws \Pterodactyl\Exceptions\DisplayValidationException

View file

@ -28,6 +28,7 @@ class HelperRepository
{
/**
* Listing of editable files in the control panel.
*
* @var array
*/
protected static $editable = [
@ -44,17 +45,13 @@ class HelperRepository
'inode/x-empty',
];
public function __construct()
{
//
}
/**
* Converts from bytes to the largest possible size that is still readable.
*
* @param int $bytes
* @param int $decimals
* @param int $bytes
* @param int $decimals
* @return string
* @deprecated
*/
public static function bytesToHuman($bytes, $decimals = 2)
{
@ -64,6 +61,11 @@ class HelperRepository
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . ' ' . $sz[$factor];
}
/**
* Returns array of editable files.
*
* @return array
*/
public static function editableFiles()
{
return self::$editable;

View file

@ -35,8 +35,9 @@ class LocationRepository
* Creates a new location on the system.
*
* @param array $data
* @throws \Pterodactyl\Exceptions\DisplayValidationException
* @return \Pterodactyl\Models\Location
*
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function create(array $data)
{
@ -58,11 +59,11 @@ class LocationRepository
/**
* Modifies a location.
*
* @param int $id
* @param array $data
* @param int $id
* @param array $data
* @return \Pterodactyl\Models\Location
*
* @throws Pterodactyl\Exceptions\DisplayValidationException
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function update($id, array $data)
{
@ -85,10 +86,10 @@ class LocationRepository
/**
* Deletes a location from the system.
*
* @param int $id
* @param int $id
* @return void
*
* @throws Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function delete($id)
{

View file

@ -34,11 +34,15 @@ use Pterodactyl\Exceptions\DisplayValidationException;
class NodeRepository
{
public function __construct()
{
//
}
/**
* Creates a new node on the system.
*
* @param array $data
* @return \Pterodactyl\Models\Node
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function create(array $data)
{
// Validate Fields
@ -84,6 +88,16 @@ class NodeRepository
return Models\Node::create($data);
}
/**
* Updates a node on the system.
*
* @param int $id
* @param array $data
* @return \Pterodactyl\Models\Node
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function update($id, array $data)
{
$node = Models\Node::findOrFail($id);
@ -179,8 +193,13 @@ class NodeRepository
/**
* Adds allocations to a provided node.
* @param int $id
* @param array $data
*
* @param int $id
* @param array $data
* @return void
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function addAllocations($id, array $data)
{
@ -243,6 +262,14 @@ class NodeRepository
});
}
/**
* Deletes a node on the system.
*
* @param int $id
* @return void
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function delete($id)
{
$node = Models\Node::withCount('servers')->findOrFail($id);

View file

@ -73,7 +73,7 @@ class OptionRepository
/**
* Deletes a service option from the system.
*
* @param int $id
* @param int $id
* @return void
*
* @throws \Pterodactyl\Exceptions\DisplayException

View file

@ -38,7 +38,7 @@ class PackRepository
/**
* Creates a new pack on the system.
*
* @param array $data
* @param array $data
* @return \Pterodactyl\Models\Pack
*
* @throws \Pterodactyl\Exceptions\DisplayException
@ -101,7 +101,7 @@ class PackRepository
/**
* Creates a new pack on the system given a template file.
*
* @param array $data
* @param array $data
* @return \Pterodactyl\Models\Pack
*
* @throws \Pterodactyl\Exceptions\DisplayException
@ -173,8 +173,8 @@ class PackRepository
/**
* Updates a pack on the system.
*
* @param int $id
* @param array $data
* @param int $id
* @param array $data
* @return \Pterodactyl\Models\Pack
*
* @throws \Pterodactyl\Exceptions\DisplayException

View file

@ -37,21 +37,21 @@ use Pterodactyl\Exceptions\DisplayValidationException;
class ServerRepository
{
/**
* An array of daemon permission to assign to this server.
*
* @var array
*/
protected $daemonPermissions = [
's:*',
];
public function __construct()
{
//
}
/**
* Generates a SFTP username for a server given a server name.
* format: mumble_67c7a4b0.
*
* @param string $name
* @param string $identifier
* @param string $name
* @param null|string $identifier
* @return string
*/
protected function generateSFTPUsername($name, $identifier = null)
@ -75,8 +75,12 @@ class ServerRepository
/**
* Adds a new server to the system.
* @param array $data An array of data descriptors for creating the server. These should align to the columns in the database.
* @return int
*
* @param array $data
* @return \Pterodactyl\Models\Server
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function create(array $data)
{
@ -341,10 +345,14 @@ class ServerRepository
}
/**
* [updateDetails description].
* @param int $id
* @param array $data
* Update the details for a server.
*
* @param int $id
* @param array $data
* @return bool
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function updateDetails($id, array $data)
{
@ -424,10 +432,14 @@ class ServerRepository
}
/**
* [updateContainer description].
* @param int $id
* @param array $data
* Update the container for a server.
*
* @param int $id
* @param array $data
* @return bool
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function updateContainer($id, array $data)
{
@ -472,10 +484,14 @@ class ServerRepository
}
/**
* [changeBuild description].
* @param int $id
* @param array $data
* @return bool
* Update the build details for a server.
*
* @param int $id
* @param array $data
* @return \Pterodactyl\Models\Server
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function changeBuild($id, array $data)
{
@ -614,6 +630,18 @@ class ServerRepository
}
}
/**
* Update the startup details for a server.
*
* @param int $id
* @param array $data
* @param bool $admin
* @return void
*
* @throws \GuzzleHttp\Exception\RequestException
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function updateStartup($id, array $data, $admin = false)
{
$server = Models\Server::with('variables', 'option.variables')->findOrFail($id);
@ -691,25 +719,34 @@ class ServerRepository
});
}
/**
* Queue a server for deletion
*
* @param int $id
* @param bool $force
* @return void
*/
public function queueDeletion($id, $force = false)
{
$server = Models\Server::findOrFail($id);
DB::beginTransaction();
try {
if ($force) {
$server->installed = 3;
$server->save();
}
DB::transaction(function () use ($force, $server) {
$server->installed = $force ? 3 : $server->installed;
$server->save();
$server->delete();
return DB::commit();
} catch (\Exception $ex) {
DB::rollBack();
throw $ex;
}
});
}
/**
* Delete a server from the system permanetly.
*
* @param int $id
* @param bool $force
* @return void
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function delete($id, $force = false)
{
$server = Models\Server::withTrashed()->with('node', 'allocations', 'variables')->findOrFail($id);
@ -774,6 +811,12 @@ class ServerRepository
});
}
/**
* Cancel the deletion of a server.
*
* @param int $id
* @return void
*/
public function cancelDeletion($id)
{
$server = Models\Server::withTrashed()->findOrFail($id);
@ -783,6 +826,14 @@ class ServerRepository
$server->save();
}
/**
* Toggle the install status of a serve.
*
* @param int $id
* @return bool
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function toggleInstall($id)
{
$server = Models\Server::findOrFail($id);
@ -795,9 +846,13 @@ class ServerRepository
}
/**
* Suspends a server instance making it unable to be booted or used by a user.
* @param int $id
* @return bool
* Suspends a server.
*
* @param int $id
* @param bool $deleted
* @return void
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function suspend($id, $deleted = false)
{
@ -831,9 +886,12 @@ class ServerRepository
}
/**
* Unsuspends a server instance.
* @param int $id
* @return bool
* Unsuspends a server.
*
* @param int $id
* @return void
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function unsuspend($id)
{
@ -866,6 +924,16 @@ class ServerRepository
}
}
/**
* Updates the SFTP password for a server.
*
* @param int $id
* @param string $password
* @return void
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function updateSFTPPassword($id, $password)
{
$server = Models\Server::with('node')->findOrFail($id);

View file

@ -37,6 +37,8 @@ class ServiceRepository
*
* @param array $data
* @return \Pterodactyl\Models\Service
*
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function create(array $data)
{
@ -80,6 +82,8 @@ class ServiceRepository
* @param int $id
* @param array $data
* @return \Pterodactyl\Models\Service
*
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function update($id, array $data)
{
@ -109,6 +113,8 @@ class ServiceRepository
*
* @param int $id
* @return void
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function delete($id)
{

View file

@ -37,6 +37,7 @@ class SubuserRepository
* Core permissions required for every subuser on the daemon.
* Without this we cannot connect the websocket or get basic
* information about the server.
*
* @var array
*/
protected $coreDaemonPermissions = [
@ -46,6 +47,7 @@ class SubuserRepository
/**
* Allowed permissions and their related daemon permission.
*
* @var array
*/
protected $permissions = [
@ -99,18 +101,15 @@ class SubuserRepository
'reset-db-password' => null,
];
public function __construct()
{
//
}
/**
* Creates a new subuser on the server.
* @param int $id The ID of the server to add this subuser to.
*
* @param int $sid
* @param array $data
* @throws DisplayValidationException
* @throws DisplayException
* @return \Pterodactyl\Models\Subuser
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function create($sid, array $data)
{
@ -202,11 +201,11 @@ class SubuserRepository
/**
* Revokes a users permissions on a server.
* @param int $id The ID of the subuser row in MySQL.
* @param array $data
* @throws DisplayValidationException
* @throws DisplayException
*
* @param int $id
* @return void
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function delete($id)
{
@ -232,8 +231,6 @@ class SubuserRepository
}
$subuser->delete();
DB::commit();
return true;
} catch (\GuzzleHttp\Exception\TransferException $ex) {
DB::rollBack();
throw new DisplayException('There was an error attempting to connect to the daemon to delete this subuser.', $ex);
@ -241,17 +238,17 @@ class SubuserRepository
DB::rollBack();
throw $ex;
}
return false;
}
/**
* Updates permissions for a given subuser.
* @param int $id The ID of the subuser row in MySQL. (Not the user ID)
*
* @param int $id
* @param array $data
* @throws DisplayValidationException
* @throws DisplayException
* @return void
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function update($id, array $data)
{
@ -304,8 +301,6 @@ class SubuserRepository
]);
DB::commit();
return true;
} catch (\GuzzleHttp\Exception\TransferException $ex) {
DB::rollBack();
throw new DisplayException('There was an error attempting to connect to the daemon to update permissions.', $ex);
@ -313,7 +308,5 @@ class SubuserRepository
DB::rollBack();
throw $ex;
}
return false;
}
}

View file

@ -32,6 +32,11 @@ use Pterodactyl\Exceptions\DisplayValidationException;
class TaskRepository
{
/**
* The default values to use for new tasks.
*
* @var array
*/
protected $defaults = [
'year' => '*',
'day_of_week' => '*',
@ -41,20 +46,20 @@ class TaskRepository
'minute' => '*/30',
];
/**
* Task action types.
*
* @var array
*/
protected $actions = [
'command',
'power',
];
public function __construct()
{
//
}
/**
* Deletes a given task.
* @param int $id
*
* @param int $id
* @return bool
*/
public function delete($id)
@ -71,8 +76,8 @@ class TaskRepository
/**
* Toggles a task active or inactive.
* @param int $id
*
* @param int $id
* @return int
*/
public function toggle($id)
@ -91,12 +96,13 @@ class TaskRepository
/**
* Create a new scheduled task for a given server.
* @param int $id
* @param array $data
*
* @throws DisplayException
* @throws DisplayValidationException
* @return void
* @param int $id
* @param array $data
* @return bool
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function create($id, $data)
{

View file

@ -38,19 +38,13 @@ use Pterodactyl\Exceptions\DisplayValidationException;
class UserRepository
{
public function __construct()
{
//
}
/**
* Creates a user on the panel. Returns the created user's ID.
*
* @param string $email
* @param string|null $password An unhashed version of the user's password.
* @param bool $admin Boolean value if user should be an admin or not.
* @param int $token A custom user ID.
* @return bool|int
* @param array $data
* @return \Pterodactyl\Models\User
*
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function create(array $data)
{
@ -118,9 +112,11 @@ class UserRepository
/**
* Updates a user on the panel.
*
* @param int $id
* @param array $data An array of columns and their associated values to update for the user.
* @param int $id
* @param array $data
* @return bool
*
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function update($id, array $data)
{
@ -157,10 +153,13 @@ class UserRepository
}
/**
* Deletes a user on the panel, returns the number of records deleted.
* Deletes a user on the panel.
*
* @param int $id
* @return int
* @return void
* @todo Move user self-deletion checking to the controller, rather than the repository.
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function delete($id)
{
@ -168,8 +167,7 @@ class UserRepository
throw new DisplayException('Cannot delete a user with active servers attached to thier account.');
}
// @TODO: this should probably be checked outside of this method because we won't always have Auth::user()
if (! is_null(Auth::user()) && Auth::user()->id === $id) {
if (! is_null(Auth::user()) && (int) Auth::user()->id === (int) $id) {
throw new DisplayException('Cannot delete your own account.');
}
@ -186,8 +184,6 @@ class UserRepository
Models\User::destroy($id);
DB::commit();
return true;
} catch (\Exception $ex) {
DB::rollBack();
throw $ex;

View file

@ -91,7 +91,7 @@ class VariableRepository
* Deletes a specified option variable as well as all server
* variables currently assigned.
*
* @param int $id
* @param int $id
* @return void
*/
public function delete($id)