◆ __construct()
__construct |
( |
|
$name, |
|
|
|
$description = null , |
|
|
|
$defaultValue = null , |
|
|
array |
$children = [] |
|
) |
| |
Creates a new Permission object to be attached to Permissible objects
- Parameters
-
string | $name | |
string | $description | |
string | $defaultValue | |
| Permission[] | $children |
103 $this->description = $description !== null ? $description :
"";
104 $this->defaultValue = $defaultValue !== null ? $defaultValue : self::$DEFAULT_PERMISSION;
105 $this->children = $children;
◆ addParent()
addParent |
( |
|
$name, |
|
|
|
$value |
|
) |
| |
- Parameters
-
- Returns
- Permission|null Permission if $name is a string, void if it's a Permission
180 if($name instanceof Permission){
181 $name->getChildren()[$this->
getName()] = $value;
182 $name->recalculatePermissibles();
187 $perm =
new Permission($name);
◆ getByName()
static getByName |
( |
|
$value | ) |
|
|
static |
- Parameters
-
- Returns
- string
54 switch(strtolower($value)){
61 return self::DEFAULT_OP;
69 return self::DEFAULT_NOT_OP;
72 return self::DEFAULT_TRUE;
75 return self::DEFAULT_FALSE;
◆ getChildren()
- Returns
- string[]
121 return $this->children;
◆ getDefault()
- Returns
- string
128 return $this->defaultValue;
◆ getDescription()
- Returns
- string
145 return $this->description;
◆ getName()
◆ getPermissibles()
◆ loadPermission()
static loadPermission |
( |
|
$name, |
|
|
array |
$data, |
|
|
|
$default = self::DEFAULT_OP , |
|
|
& |
$output = [] |
|
) |
| |
|
static |
- Parameters
-
string | $name | |
array | $data | |
string | $default | |
array | $output | |
- Returns
- Permission
- Exceptions
-
225 if(isset($data[
"default"])){
230 throw new \InvalidStateException(
"'default' key contained unknown value");
234 if(isset($data[
"children"])){
235 if(is_array($data[
"children"])){
236 foreach($data[
"children"] as $k => $v){
238 if(($perm = self::loadPermission($k, $v, $default, $output)) !== null){
242 $children[$k] =
true;
245 throw new \InvalidStateException(
"'children' key is of wrong type");
249 if(isset($data[
"description"])){
250 $desc = $data[
"description"];
253 return new Permission($name, $desc, $default, $children);
◆ loadPermissions()
static loadPermissions |
( |
array |
$data, |
|
|
|
$default = self::DEFAULT_OP |
|
) |
| |
|
static |
- Parameters
-
- Returns
- Permission[]
205 foreach($data as $key => $entry){
206 $result[] = self::loadPermission($key, $entry, $default, $result);
◆ recalculatePermissibles()
recalculatePermissibles |
( |
| ) |
|
167 foreach($perms as $p){
168 $p->recalculatePermissions();
◆ setDefault()
- Parameters
-
135 if($value !== $this->defaultValue){
136 $this->defaultValue = $value;
◆ setDescription()
- Parameters
-
152 $this->description = $value;
◆ $DEFAULT_PERMISSION
$DEFAULT_PERMISSION = self::DEFAULT_OP |
|
static |
◆ DEFAULT_FALSE
const DEFAULT_FALSE = "false" |
◆ DEFAULT_NOT_OP
const DEFAULT_NOT_OP = "notop" |
◆ DEFAULT_OP
◆ DEFAULT_TRUE
const DEFAULT_TRUE = "true" |
The documentation for this class was generated from the following file:
- src/pocketmine/permission/Permission.php