Group
extends Data
in package
Class Data
Use $grav['user_groups'] instead of this class. In type hints, please use UserGroupInterface.
Table of Contents
Properties
- $blueprints : Blueprint|callable|null
- $gettersVariable : string
- $items : array<string|int, mixed>
- $storage : FileInterface|null
Methods
- __construct() : mixed
- blueprints() : Blueprint
- Return blueprints.
- exists() : bool
- Returns whether the data already exists in the storage.
- extra() : array<string|int, mixed>
- Get extra items which haven't been defined in blueprints.
- file() : FileInterface|null
- Set or get the data storage.
- filter() : $this
- Filter all items by using blueprints.
- getDefaults() : array<string|int, mixed>
- Get nested structure containing default values defined in the blueprints.
- getJoined() : array<string|int, mixed>
- Get value from the configuration and join it with given data.
- groupExists() : bool
- Checks if a group exists
- groupNames() : array<string|int, mixed>
- Get the groups list
- join() : $this
- Join nested values together by using blueprints.
- joinDefaults() : $this
- Set default values by using blueprints.
- jsonSerialize() : array<string|int, mixed>
- load() : object
- Get a group by name
- merge() : $this
- Merge two configurations together.
- raw() : string
- Return unmodified data as raw string.
- remove() : bool
- Remove a group
- save() : void
- Save a group
- setDefaults() : $this
- Set default values to the configuration if variables were not set.
- setKeepEmptyValues() : $this
- setMissingValuesAsNull() : $this
- validate() : $this
- Validate by blueprints.
- value() : mixed
- Get value by using dot notation for nested arrays/objects.
- groups() : array<string|int, mixed>
- Get the groups list
Properties
$blueprints
protected
Blueprint|callable|null
$blueprints
$gettersVariable
protected
string
$gettersVariable
= 'items'
$items
protected
array<string|int, mixed>
$items
$storage
protected
FileInterface|null
$storage
Methods
__construct()
public
__construct([array<string|int, mixed> $items = [] ][, Blueprint|callable|null $blueprints = null ]) : mixed
Parameters
- $items : array<string|int, mixed> = []
- $blueprints : Blueprint|callable|null = null
blueprints()
Return blueprints.
public
blueprints() : Blueprint
Return values
Blueprintexists()
Returns whether the data already exists in the storage.
public
exists() : bool
NOTE: This method does not check if the data is current.
Return values
boolextra()
Get extra items which haven't been defined in blueprints.
public
extra() : array<string|int, mixed>
Return values
array<string|int, mixed>file()
Set or get the data storage.
public
file([FileInterface|null $storage = null ]) : FileInterface|null
Parameters
- $storage : FileInterface|null = null
-
Optionally enter a new storage.
Return values
FileInterface|nullfilter()
Filter all items by using blueprints.
public
filter() : $this
Return values
$thisgetDefaults()
Get nested structure containing default values defined in the blueprints.
public
getDefaults() : array<string|int, mixed>
Fields without default value are ignored in the list.
Return values
array<string|int, mixed>getJoined()
Get value from the configuration and join it with given data.
public
getJoined(string $name, array<string|int, mixed>|object $value[, string $separator = '.' ]) : array<string|int, mixed>
Parameters
- $name : string
-
Dot separated path to the requested value.
- $value : array<string|int, mixed>|object
-
Value to be joined.
- $separator : string = '.'
-
Separator, defaults to '.'
Tags
Return values
array<string|int, mixed>groupExists()
Checks if a group exists
public
static groupExists(string $groupname) : bool
use $grav['user_groups'] Flex UserGroupCollection instead
Parameters
- $groupname : string
Return values
boolgroupNames()
Get the groups list
public
static groupNames() : array<string|int, mixed>
use $grav['user_groups'] Flex UserGroupCollection instead
Return values
array<string|int, mixed>join()
Join nested values together by using blueprints.
public
join(string $name, mixed $value[, string $separator = '.' ]) : $this
Parameters
- $name : string
-
Dot separated path to the requested value.
- $value : mixed
-
Value to be joined.
- $separator : string = '.'
-
Separator, defaults to '.'
Tags
Return values
$thisjoinDefaults()
Set default values by using blueprints.
public
joinDefaults(string $name, mixed $value[, string $separator = '.' ]) : $this
Parameters
- $name : string
-
Dot separated path to the requested value.
- $value : mixed
-
Value to be joined.
- $separator : string = '.'
-
Separator, defaults to '.'
Return values
$thisjsonSerialize()
public
jsonSerialize() : array<string|int, mixed>
Attributes
- #[ReturnTypeWillChange]
Return values
array<string|int, mixed>load()
Get a group by name
public
static load(string $groupname) : object
use $grav['user_groups'] Flex UserGroupCollection instead
Parameters
- $groupname : string
Return values
objectmerge()
Merge two configurations together.
public
merge(array<string|int, mixed> $data) : $this
Parameters
- $data : array<string|int, mixed>
Return values
$thisraw()
Return unmodified data as raw string.
public
raw() : string
NOTE: This function only returns data which has been saved to the storage.
Return values
stringremove()
Remove a group
public
static remove(string $groupname) : bool
use $grav['user_groups'] Flex UserGroupCollection instead
Parameters
- $groupname : string
Return values
bool —True if the action was performed
save()
Save a group
public
save() : void
setDefaults()
Set default values to the configuration if variables were not set.
public
setDefaults(array<string|int, mixed> $data) : $this
Parameters
- $data : array<string|int, mixed>
Return values
$thissetKeepEmptyValues()
public
setKeepEmptyValues(bool $value) : $this
Parameters
- $value : bool
Return values
$thissetMissingValuesAsNull()
public
setMissingValuesAsNull(bool $value) : $this
Parameters
- $value : bool
Return values
$thisvalidate()
Validate by blueprints.
public
validate() : $this
Tags
Return values
$thisvalue()
Get value by using dot notation for nested arrays/objects.
public
value(string $name[, mixed $default = null ][, string $separator = '.' ]) : mixed
Parameters
- $name : string
-
Dot separated path to the requested value.
- $default : mixed = null
-
Default value (or null).
- $separator : string = '.'
-
Separator, defaults to '.'
Tags
Return values
mixed —Value.
groups()
Get the groups list
protected
static groups() : array<string|int, mixed>
use $grav['user_groups'] Flex UserGroupCollection instead