Refactor startup modification and environment variable services
Better setup, more flexibility, more tests.
This commit is contained in:
parent
7022ec788f
commit
fa62a0982e
19 changed files with 660 additions and 563 deletions
44
app/Traits/Services/HasUserLevels.php
Normal file
44
app/Traits/Services/HasUserLevels.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Traits\Services;
|
||||
|
||||
use Pterodactyl\Models\User;
|
||||
|
||||
trait HasUserLevels
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $userLevel = User::USER_LEVEL_USER;
|
||||
|
||||
/**
|
||||
* Set the access level for running this function.
|
||||
*
|
||||
* @param int $level
|
||||
*/
|
||||
public function setUserLevel(int $level)
|
||||
{
|
||||
$this->userLevel = $level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine which level this function is running at.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getUserLevel(): int
|
||||
{
|
||||
return $this->userLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the current user level is set to a specific level.
|
||||
*
|
||||
* @param int $level
|
||||
* @return bool
|
||||
*/
|
||||
public function isUserLevel(int $level): bool
|
||||
{
|
||||
return $this->getUserLevel() === $level;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue