UserObject
extends FlexObject
in package
implements
UserInterface, Countable
uses
FlexGravTrait, FlexObjectTrait, FlexMediaTrait, UserTrait, UserObjectLegacyTrait, FlexRelationshipsTrait
Flex User
Flex User is mostly compatible with the older User class, except on few key areas:
- Constructor parameters have been changed. Old code creating a new user does not work.
- Serializer has been changed -- existing sessions will be killed.
Table of Contents
Interfaces
- UserInterface
- Interface UserInterface
- Countable
Properties
- $authenticated : bool
- $authorizeCallable : Closure|null
- $authorized : bool
- $email : string
- $fullname : string
- $groups : array<string|int, mixed>
- $isAuthorizedCallable : Closure|null
- $state : string
- $username : string
- $_access : Access
- $_groups : UserGroupIndex
- $_original : array<string|int, mixed>|null
- $_storage : FileInterface|null
- $_uploads : array<string|int, mixed>
- $_uploads_original : array<string|int, mixed>|null
- $access : array<string|int, mixed>|null
- $storage_key : string|null
- $storage_timestamp : int|null
- $type : string
- $_key : string
- $_relationships : RelationshipsInterface|null
Methods
- __clone() : mixed
- Clone object.
- __construct() : mixed
- UserObject constructor.
- __debugInfo() : array<string|int, mixed>
- __get() : mixed
- Returns the value at specified offset.
- __isset() : bool
- Checks whether or not an offset exists.
- __serialize() : array<string|int, mixed>
- __set() : void
- Assigns a value to the specified offset.
- __toString() : string
- Returns a string representation of this object.
- __unserialize() : void
- __unset() : void
- Magic method to unset the attribute
- authenticate() : bool
- Authenticate user.
- authorise() : bool
- Checks user authorization to the action.
- authorize() : bool|null
- Checks user authorization to the action.
- avatarUrl() : string
- Return the User's avatar URL
- blueprints() : Blueprint
- Alias of getBlueprint()
- check() : void
- checkMediaFilename() : void
- count() : int
- Implements Countable interface.
- create() : static
- Create new object into the storage.
- createCopy() : FlexObject|FlexObjectInterface
- createFromStorage() : static
- def() : $this
- Set default value by using dot notation for nested arrays/objects.
- defNestedProperty() : $this
- defProperty() : $this
- delete() : static
- Delete object from the storage.
- exists() : bool
- Returns true if the object 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.
- get() : mixed
- Get value by using dot notation for nested arrays/objects.
- getAvatarImage() : ImageMedium|StaticImageMedium|null
- Return media object for the User's avatar.
- getAvatarMedia() : ImageMedium|StaticImageMedium|null
- Return media object for the User's avatar.
- getAvatarUrl() : string
- Return the User's avatar URL
- getBlueprint() : Blueprint
- Returns the blueprint of the object.
- getCache() : CacheInterface
- getCacheChecksum() : string
- Get cache checksum for the object / collection.
- getCachedMethods() : array<string|int, mixed>
- getCacheKey() : string
- Get a cache key which is used for caching the object / collection.
- getChanges() : array<string|int, mixed>
- Get any changes from the object.
- getContentEditor() : string
- Helper to get content editor will fall back if not set
- getDefaults() : array<string|int, mixed>
- Get nested structure containing default values defined in the blueprints.
- getDefaultValue() : mixed|null
- Returns default value suitable to be used in a form for the given property.
- getDefaultValues() : array<string|int, mixed>
- Returns default values suitable to be used in a form for the given property.
- getDiff() : array<string|int, mixed>
- Get diff array from the object.
- getFieldSettings() : array<string|int, mixed>|null
- getFlexDirectory() : FlexDirectory
- getFlexFeatures() : array<string|int, mixed>
- Get full list of features the object / collection implements.
- getFlexKey() : string
- Get a unique key for the object.
- getFlexType() : string
- Get Flex Type of the object / collection.
- getForm() : FlexFormInterface
- Returns a form instance for the object.
- getFormValue() : mixed
- Returns raw value suitable to be used in a form for the given property.
- getJoined() : array<string|int, mixed>
- Get value from the configuration and join it with given data.
- getKey() : string
- getMedia() : MediaCollectionInterface
- Gets the associated media collection.
- getMediaField() : MediaCollectionInterface|null
- getMediaFolder() : string|null
- Get filesystem path to the associated media.
- getMetaData() : array<string|int, mixed>
- Get index data associated to the object.
- getNestedProperty() : mixed
- getOriginalData() : array<string|int, mixed>
- Get original data before update
- getProperty() : mixed
- getRelationship() : RelationshipInterface|null
- getRelationships() : Relationships
- getRoles() : UserGroupIndex
- getStorageFolder() : string|null
- getStorageKey() : string
- getTimestamp() : int
- Get last updated timestamp for the object / collection.
- getType() : string
- hasFlexFeature() : bool
- Test whether the feature is implemented in the object / collection.
- hasKey() : bool
- hasNestedProperty() : bool
- hasProperty() : bool
- isAuthorized() : bool|null
- Check if user is authorized for the action.
- isMyself() : bool
- isValid() : bool
- join() : $this
- Join nested values together by using blueprints.
- joinDefaults() : $this
- Set default values by using blueprints.
- jsonSerialize() : array<string|int, mixed>
- merge() : $this
- Merge two configurations together.
- offsetExists() : bool
- Whether or not an offset exists.
- offsetGet() : mixed
- Returns the value at specified offset.
- offsetSet() : void
- Assigns a value to the specified offset.
- offsetUnset() : void
- Unsets an offset.
- onPrepareRegistration() : void
- prepareStorage() : array<string|int, mixed>
- Prepare object for saving into the storage.
- raw() : string
- Return unmodified data as raw string.
- refresh() : bool
- Refresh object from the storage.
- render() : ContentBlockInterface|HtmlBlock
- Renders the object.
- save() : static
- Save user
- search() : float
- Search a string from the object, returns weight between 0 and 1.
- searchNestedProperty() : float
- searchProperty() : float
- set() : $this
- Set value by using dot notation for nested arrays/objects.
- setDefaults() : $this
- Set default values to the configuration if variables were not set.
- setFlexDirectory() : void
- setNestedProperty() : $this
- setProperty() : $this
- setStorageKey() : $this
- setTimestamp() : $this
- toArray() : array<string|int, mixed>
- Convert object into an array.
- toJson() : string
- Convert object into JSON string.
- toYaml() : string
- Convert object into YAML string.
- triggerEvent() : $this
- undef() : $this
- Unset value by using dot notation for nested arrays/objects.
- unsetNestedProperty() : $this
- unsetProperty() : $this
- update() : static
- Updates object in the memory.
- validate() : $this
- Validate by blueprints.
- value() : mixed
- addUpdatedMedia() : void
- buildFlexIdentifierList() : array<string|int, mixed>
- buildMediaList() : array<string|int, mixed>
- buildMediaObject() : MediaObject|UploadedMediaObject
- createFormObject() : FlexFormInterface
- This methods allows you to override form objects in child classes.
- createMedium() : Medium|null
- doGetBlueprint() : Blueprint
- doGetProperty() : mixed
- doHasProperty() : bool
- doSerialize() : array<string|int, mixed>
- doSetProperty() : void
- doUnserialize() : void
- doUnsetProperty() : void
- filterElements() : void
- Filter data coming to constructor or $this->update() request.
- freeMedia() : void
- generateMultiavatar() : string
- getAccess() : Access
- getActiveUser() : UserInterface|null
- getAuthorizeAction() : string
- getAuthorizeRule() : string
- getAuthorizeScope() : string
- getAvatarFile() : string|null
- getCollectionByProperty() : FlexCollectionInterface<string|int, FlexObjectInterface>
- getContainer() : Grav
- getElement() : mixed|null
- getElements() : array<string|int, mixed>
- getFlexContainer() : Flex
- getGroups() : UserGroupIndex
- getMediaCache() : CacheInterface
- getMediaFields() : array<string|int, mixed>
- getOriginalMedia() : MediaCollectionInterface
- Gets the associated media collection (original images).
- getRelatedDirectory() : FlexDirectory
- getStorage() : array<string|int, mixed>
- getTemplate() : Template|TemplateWrapper
- getTemplateConfig() : array<string|int, mixed>
- getTemplatePaths() : array<string|int, mixed>
- getTypePrefix() : string
- getUpdatedMedia() : array<string, UploadedFileInterface|array<string|int, mixed>|null>
- getUserGroups() : UserGroupIndex
- isAdminSite() : bool
- isAuthorizedAction() : bool|null
- Check if user is authorized for the action.
- isAuthorizedOverride() : bool|null
- isAuthorizedSuperAdmin() : bool|null
- markAsCopy() : void
- offsetLoad_access() : array<string|int, mixed>
- offsetLoad_media() : MediaCollectionInterface
- offsetPrepare_access() : array<string|int, mixed>
- offsetSerialize_access() : array<string|int, mixed>|null
- offsetSerialize_media() : null
- parseFileProperty() : array<string|int, mixed>|mixed
- resetBlueprints() : void
- Method to reset blueprints if the type changes.
- resetRelationships() : void
- saveUpdatedMedia() : void
- searchValue() : float
- setKey() : $this
- setMetaData() : void
- setStorage() : void
- setUpdatedMedia() : void
- updateAvatarRelationship() : void
- updateRelationships() : bool
Properties
$authenticated
public
bool
$authenticated
$authorizeCallable
public
static Closure|null
$authorizeCallable
$authorized
public
bool
$authorized
public
string
$email
$fullname
public
string
$fullname
$groups
public
array<string|int, mixed>
$groups
$isAuthorizedCallable
public
static Closure|null
$isAuthorizedCallable
$state
public
string
$state
$username
public
string
$username
$_access
protected
Access
$_access
$_groups
protected
UserGroupIndex
$_groups
$_original
protected
array<string|int, mixed>|null
$_original
$_storage
protected
FileInterface|null
$_storage
$_uploads
protected
array<string|int, mixed>
$_uploads
= []
$_uploads_original
protected
array<string|int, mixed>|null
$_uploads_original
$access
protected
array<string|int, mixed>|null
$access
$storage_key
protected
string|null
$storage_key
$storage_timestamp
protected
int|null
$storage_timestamp
$type
protected
static string
$type
$_key
private
string
$_key
$_relationships
private
RelationshipsInterface|null
$_relationships
= null
Methods
__clone()
Clone object.
public
__clone() : mixed
__construct()
UserObject constructor.
public
__construct(array<string|int, mixed> $elements, string $key, FlexDirectory $directory[, bool $validate = false ]) : mixed
Parameters
- $elements : array<string|int, mixed>
- $key : string
- $directory : FlexDirectory
- $validate : bool = false
__debugInfo()
public
__debugInfo() : array<string|int, mixed>
Attributes
- #[ReturnTypeWillChange]
Return values
array<string|int, mixed>__get()
Returns the value at specified offset.
public
__get(mixed $offset) : mixed
Parameters
- $offset : mixed
-
The offset to retrieve.
Attributes
- #[ReturnTypeWillChange]
Return values
mixed —Can return all value types.
__isset()
Checks whether or not an offset exists.
public
__isset(mixed $offset) : bool
Parameters
- $offset : mixed
-
An offset to check for.
Attributes
- #[ReturnTypeWillChange]
Return values
bool —Returns TRUE on success or FALSE on failure.
__serialize()
public
final __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>__set()
Assigns a value to the specified offset.
public
__set(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
-
The offset to assign the value to.
- $value : mixed
-
The value to set.
Attributes
- #[ReturnTypeWillChange]
__toString()
Returns a string representation of this object.
public
__toString() : string
Attributes
- #[ReturnTypeWillChange]
Return values
string__unserialize()
public
final __unserialize(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
__unset()
Magic method to unset the attribute
public
__unset(mixed $offset) : void
Parameters
- $offset : mixed
-
The name value to unset
Attributes
- #[ReturnTypeWillChange]
authenticate()
Authenticate user.
public
authenticate(string $password) : bool
If user password needs to be updated, new information will be saved.
Parameters
- $password : string
-
Plaintext password.
Return values
boolauthorise()
Checks user authorization to the action.
public
authorise(string $action) : bool
Use ->authorize() method instead.
Ensures backwards compatibility
Parameters
- $action : string
Return values
boolauthorize()
Checks user authorization to the action.
public
authorize(string $action[, string|null $scope = null ]) : bool|null
Parameters
- $action : string
- $scope : string|null = null
Return values
bool|nullavatarUrl()
Return the User's avatar URL
public
avatarUrl() : string
Use ->getAvatarUrl() method instead.
Return values
stringblueprints()
Alias of getBlueprint()
public
blueprints() : Blueprint
Admin compatibility
Return values
Blueprintcheck()
public
check([UserInterface|null $user = null ]) : void
Parameters
- $user : UserInterface|null = null
checkMediaFilename()
public
checkMediaFilename(string $filename) : void
Use Media class that implements MediaUploadInterface instead.
Parameters
- $filename : string
count()
Implements Countable interface.
public
count() : int
Method makes no sense for user account.
Attributes
- #[ReturnTypeWillChange]
Return values
intcreate()
Create new object into the storage.
public
create([string $key = null ]) : static
Parameters
- $key : string = null
-
Optional new key. If key isn't given, random key will be associated to the object.
Tags
Return values
staticcreateCopy()
public
createCopy([string|null $key = null ]) : FlexObject|FlexObjectInterface
Parameters
- $key : string|null = null
Return values
FlexObject|FlexObjectInterfacecreateFromStorage()
public
static createFromStorage(array<string|int, mixed> $elements, array<string|int, mixed> $storage, FlexDirectory $directory[, bool $validate = false ]) : static
Parameters
- $elements : array<string|int, mixed>
- $storage : array<string|int, mixed>
- $directory : FlexDirectory
- $validate : bool = false
Return values
staticdef()
Set default value by using dot notation for nested arrays/objects.
public
def(string $name[, mixed $default = null ][, string|null $separator = null ]) : $this
Parameters
- $name : string
-
Dot separated path to the requested value.
- $default : mixed = null
-
Default value (or null).
- $separator : string|null = null
-
Separator, defaults to '.'
Tags
Return values
$thisdefNestedProperty()
public
defNestedProperty(string $property, mixed $default[, string|null $separator = null ]) : $this
Parameters
- $property : string
-
Object property to be updated.
- $default : mixed
-
Default value.
- $separator : string|null = null
-
Separator, defaults to '.'
Tags
Return values
$thisdefProperty()
public
defProperty(string $property, mixed $default) : $this
Parameters
- $property : string
-
Object property to be defined.
- $default : mixed
-
Default value.
Return values
$thisdelete()
Delete object from the storage.
public
delete() : static
Tags
Return values
staticexists()
Returns true if the object exists in the storage.
public
exists() : bool
Tags
Return values
bool —Returns true if the object exists, false otherwise.
extra()
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
$thisget()
Get value by using dot notation for nested arrays/objects.
public
get(string $name[, mixed $default = null ][, string|null $separator = null ]) : mixed
Parameters
- $name : string
-
Dot separated path to the requested value.
- $default : mixed = null
-
Default value (or null).
- $separator : string|null = null
-
Separator, defaults to '.'
Tags
Return values
mixed —Value.
getAvatarImage()
Return media object for the User's avatar.
public
getAvatarImage() : ImageMedium|StaticImageMedium|null
Note: if there's no local avatar image for the user, you should call getAvatarUrl() to get the external avatar URL.
Return values
ImageMedium|StaticImageMedium|nullgetAvatarMedia()
Return media object for the User's avatar.
public
getAvatarMedia() : ImageMedium|StaticImageMedium|null
Use ->getAvatarImage() method instead.
Return values
ImageMedium|StaticImageMedium|nullgetAvatarUrl()
Return the User's avatar URL
public
getAvatarUrl() : string
Return values
stringgetBlueprint()
Returns the blueprint of the object.
public
getBlueprint([string $name = '' ]) : Blueprint
Parameters
- $name : string = ''
-
Name of the Blueprint form. Used to create customized forms for different use cases.
Tags
Return values
Blueprint —Returns a Blueprint.
getCache()
public
getCache([string|null $namespace = null ]) : CacheInterface
Parameters
- $namespace : string|null = null
Return values
CacheInterfacegetCacheChecksum()
Get cache checksum for the object / collection.
public
getCacheChecksum() : string
Tags
Return values
string —Returns cache checksum.
getCachedMethods()
public
static getCachedMethods() : array<string|int, mixed>
Return values
array<string|int, mixed>getCacheKey()
Get a cache key which is used for caching the object / collection.
public
getCacheKey() : string
Tags
Return values
string —Returns cache key.
getChanges()
Get any changes from the object.
public
getChanges() : array<string|int, mixed>
Return values
array<string|int, mixed>getContentEditor()
Helper to get content editor will fall back if not set
public
getContentEditor() : string
Return values
stringgetDefaults()
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>getDefaultValue()
Returns default value suitable to be used in a form for the given property.
public
getDefaultValue(string $name[, string $separator = null ]) : mixed|null
Parameters
- $name : string
-
Property name.
- $separator : string = null
-
Optional nested property separator.
Tags
Return values
mixed|null —Returns default value of the field, null if there is no default value.
getDefaultValues()
Returns default values suitable to be used in a form for the given property.
public
getDefaultValues() : array<string|int, mixed>
Return values
array<string|int, mixed>getDiff()
Get diff array from the object.
public
getDiff() : array<string|int, mixed>
Return values
array<string|int, mixed>getFieldSettings()
public
getFieldSettings(string $field) : array<string|int, mixed>|null
Parameters
- $field : string
Return values
array<string|int, mixed>|nullgetFlexDirectory()
public
abstract getFlexDirectory() : FlexDirectory
Return values
FlexDirectorygetFlexFeatures()
Get full list of features the object / collection implements.
public
getFlexFeatures() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getFlexKey()
Get a unique key for the object.
public
getFlexKey() : string
Tags
Return values
string —Returns Flex Key of the object.
getFlexType()
Get Flex Type of the object / collection.
public
getFlexType() : string
Tags
Return values
string —Returns Flex Type of the collection.
getForm()
Returns a form instance for the object.
public
getForm([string $name = '' ][, array<string|int, mixed> $options = null ]) : FlexFormInterface
Parameters
- $name : string = ''
-
Name of the form. Can be used to create customized forms for different use cases.
- $options : array<string|int, mixed> = null
-
Options can be used to further customize the form.
Tags
Return values
FlexFormInterface —Returns a Form.
getFormValue()
Returns raw value suitable to be used in a form for the given property.
public
getFormValue(string $name[, mixed $default = null ][, string $separator = null ]) : mixed
Parameters
- $name : string
-
Property name.
- $default : mixed = null
-
Default value.
- $separator : string = null
-
Optional nested property separator.
Tags
Return values
mixed —Returns value of the field.
getJoined()
Get value from the configuration and join it with given data.
public
getJoined(string $name, array<string|int, mixed>|object $value[, string $separator = null ]) : 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 = null
-
Separator, defaults to '.'
Tags
Return values
array<string|int, mixed>getKey()
public
getKey() : string
Tags
Return values
stringgetMedia()
Gets the associated media collection.
public
getMedia() : MediaCollectionInterface
Return values
MediaCollectionInterfacegetMediaField()
public
getMediaField(string $field) : MediaCollectionInterface|null
Parameters
- $field : string
Return values
MediaCollectionInterface|nullgetMediaFolder()
Get filesystem path to the associated media.
public
getMediaFolder() : string|null
Return values
string|nullgetMetaData()
Get index data associated to the object.
public
getMetaData() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —Returns metadata of the object.
getNestedProperty()
public
getNestedProperty(string $property[, mixed|null $default = null ][, string|null $separator = null ]) : mixed
Parameters
- $property : string
-
Object property to be fetched.
- $default : mixed|null = null
-
Default value if property has not been set.
- $separator : string|null = null
-
Separator, defaults to '.'
Return values
mixed —Property value.
getOriginalData()
Get original data before update
public
getOriginalData() : array<string|int, mixed>
Return values
array<string|int, mixed>getProperty()
public
getProperty(string $property[, mixed $default = null ]) : mixed
Parameters
- $property : string
- $default : mixed = null
getRelationship()
public
getRelationship(string $name) : RelationshipInterface|null
Parameters
- $name : string
Return values
RelationshipInterface|nullgetRelationships()
public
getRelationships() : Relationships
Return values
RelationshipsgetRoles()
public
getRoles() : UserGroupIndex
Return values
UserGroupIndexgetStorageFolder()
public
getStorageFolder() : string|null
Return values
string|nullgetStorageKey()
public
abstract getStorageKey() : string
Return values
stringgetTimestamp()
Get last updated timestamp for the object / collection.
public
getTimestamp() : int
Tags
Return values
int —Returns Unix timestamp.
getType()
public
getType([bool $prefix = false ]) : string
Use ->getFlexType() instead.
Parameters
- $prefix : bool = false
Return values
stringhasFlexFeature()
Test whether the feature is implemented in the object / collection.
public
hasFlexFeature(string $name) : bool
Parameters
- $name : string
Tags
Return values
boolhasKey()
public
hasKey() : bool
Return values
boolhasNestedProperty()
public
hasNestedProperty(string $property[, string|null $separator = null ]) : bool
Parameters
- $property : string
-
Object property name.
- $separator : string|null = null
-
Separator, defaults to '.'
Return values
bool —True if property has been defined (can be null).
hasProperty()
public
hasProperty(string $property) : bool
Parameters
- $property : string
-
Object property name.
Return values
bool —True if property has been defined (can be null).
isAuthorized()
Check if user is authorized for the action.
public
isAuthorized(string $action[, string|null $scope = null ][, UserInterface|null $user = null ]) : bool|null
Note: There are two deny values: denied (false), not set (null). This allows chaining multiple rules together when the previous rules were not matched.
To override the default behavior, please use isAuthorizedOverride().
Parameters
- $action : string
- $scope : string|null = null
- $user : UserInterface|null = null
Tags
Return values
bool|nullisMyself()
public
isMyself([UserInterface|null $user = null ]) : bool
Parameters
- $user : UserInterface|null = null
Return values
boolisValid()
public
isValid() : bool
Return values
booljoin()
Join nested values together by using blueprints.
public
join(string $name, mixed $value[, string|null $separator = null ]) : $this
Parameters
- $name : string
-
Dot separated path to the requested value.
- $value : mixed
-
Value to be joined.
- $separator : string|null = null
-
Separator, defaults to '.'
Tags
Return values
$thisjoinDefaults()
Set default values by using blueprints.
public
joinDefaults(string $name, mixed $value[, string|null $separator = null ]) : $this
Parameters
- $name : string
-
Dot separated path to the requested value.
- $value : mixed
-
Value to be joined.
- $separator : string|null = null
-
Separator, defaults to '.'
Return values
$thisjsonSerialize()
public
jsonSerialize() : array<string|int, mixed>
Attributes
- #[ReturnTypeWillChange]
Return values
array<string|int, mixed>merge()
Merge two configurations together.
public
merge(array<string|int, mixed> $data) : $this
Use ->update($data) instead (same but with data validation & filtering, file upload support).
Parameters
- $data : array<string|int, mixed>
Return values
$thisoffsetExists()
Whether or not an offset exists.
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
-
An offset to check for.
Attributes
- #[ReturnTypeWillChange]
Return values
bool —Returns TRUE on success or FALSE on failure.
offsetGet()
Returns the value at specified offset.
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
-
The offset to retrieve.
Attributes
- #[ReturnTypeWillChange]
Return values
mixed —Can return all value types.
offsetSet()
Assigns a value to the specified offset.
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
-
The offset to assign the value to.
- $value : mixed
-
The value to set.
Attributes
- #[ReturnTypeWillChange]
offsetUnset()
Unsets an offset.
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
-
The offset to unset.
Attributes
- #[ReturnTypeWillChange]
onPrepareRegistration()
public
onPrepareRegistration() : void
prepareStorage()
Prepare object for saving into the storage.
public
prepareStorage() : array<string|int, mixed>
Return values
array<string|int, mixed>raw()
Return unmodified data as raw string.
public
raw() : string
NOTE: This function only returns data which has been saved to the storage.
Return values
stringrefresh()
Refresh object from the storage.
public
refresh([bool $keepMissing = false ]) : bool
Parameters
- $keepMissing : bool = false
Return values
bool —True if the object was refreshed
render()
Renders the object.
public
render([string $layout = null ][, array<string|int, mixed> $context = [] ]) : ContentBlockInterface|HtmlBlock
Parameters
- $layout : string = null
-
Layout to be used.
- $context : array<string|int, mixed> = []
-
Extra context given to the renderer.
Tags
Return values
ContentBlockInterface|HtmlBlock —Returns HtmlBlock containing the rendered output.
save()
Save user
public
save() : static
Return values
staticsearch()
Search a string from the object, returns weight between 0 and 1.
public
search(string $search[, mixed $properties = null ][, array<string|int, mixed> $options = null ]) : float
Parameters
- $search : string
-
Search string.
- $properties : mixed = null
-
Properties to search for, defaults to configured properties.
- $options : array<string|int, mixed> = null
-
Search options, defaults to configured options.
Tags
Return values
float —Returns a weight between 0 and 1.
searchNestedProperty()
public
searchNestedProperty(string $property, string $search[, array<string|int, mixed>|null $options = null ]) : float
Parameters
- $property : string
- $search : string
- $options : array<string|int, mixed>|null = null
Return values
floatsearchProperty()
public
searchProperty(string $property, string $search[, array<string|int, mixed>|null $options = null ]) : float
Parameters
- $property : string
- $search : string
- $options : array<string|int, mixed>|null = null
Return values
floatset()
Set value by using dot notation for nested arrays/objects.
public
set(string $name, mixed $value[, string|null $separator = null ]) : $this
Parameters
- $name : string
-
Dot separated path to the requested value.
- $value : mixed
-
New value.
- $separator : string|null = null
-
Separator, defaults to '.'
Tags
Return values
$thissetDefaults()
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
$thissetFlexDirectory()
public
setFlexDirectory(FlexDirectory $directory) : void
Parameters
- $directory : FlexDirectory
setNestedProperty()
public
setNestedProperty(string $property, mixed $value[, string|null $separator = null ]) : $this
Parameters
- $property : string
-
Object property to be updated.
- $value : mixed
-
New value.
- $separator : string|null = null
-
Separator, defaults to '.'
Tags
Return values
$thissetProperty()
public
setProperty(string $property, mixed $value) : $this
Parameters
- $property : string
-
Object property to be updated.
- $value : mixed
-
New value.
Return values
$thissetStorageKey()
public
setStorageKey([string|null $key = null ]) : $this
Parameters
- $key : string|null = null
Return values
$thissetTimestamp()
public
setTimestamp([int $timestamp = null ]) : $this
Parameters
- $timestamp : int = null
Return values
$thistoArray()
Convert object into an array.
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>toJson()
Convert object into JSON string.
public
toJson() : string
Return values
stringtoYaml()
Convert object into YAML string.
public
toYaml([int $inline = 5 ][, int $indent = 2 ]) : string
Parameters
- $inline : int = 5
-
The level where you switch to inline YAML.
- $indent : int = 2
-
The amount of spaces to use for indentation of nested nodes.
Return values
string —A YAML string representing the object.
triggerEvent()
public
triggerEvent(string $name[, object|null $event = null ]) : $this
Parameters
- $name : string
- $event : object|null = null
Return values
$thisundef()
Unset value by using dot notation for nested arrays/objects.
public
undef(string $name[, string|null $separator = null ]) : $this
Parameters
- $name : string
-
Dot separated path to the requested value.
- $separator : string|null = null
-
Separator, defaults to '.'
Tags
Return values
$thisunsetNestedProperty()
public
unsetNestedProperty(string $property[, string|null $separator = null ]) : $this
Parameters
- $property : string
-
Object property to be updated.
- $separator : string|null = null
-
Separator, defaults to '.'
Tags
Return values
$thisunsetProperty()
public
unsetProperty(string $property) : $this
Parameters
- $property : string
-
Object property to be unset.
Return values
$thisupdate()
Updates object in the memory.
public
update(array<string|int, mixed> $data[, array<string|int, mixed> $files = [] ]) : static
Parameters
- $data : array<string|int, mixed>
-
Data containing updated properties with their values. To unset a value, use
null. - $files : array<string|int, mixed> = []
-
List of uploaded files to be saved within the object.
Tags
Return values
staticvalidate()
Validate by blueprints.
public
validate() : $this
Tags
Return values
$thisvalue()
public
value(string $name[, mixed|null $default = null ][, string|null $separator = null ]) : mixed
Use ->getFormValue() method instead.
Parameters
- $name : string
- $default : mixed|null = null
- $separator : string|null = null
addUpdatedMedia()
protected
addUpdatedMedia(MediaCollectionInterface $media) : void
Parameters
- $media : MediaCollectionInterface
buildFlexIdentifierList()
protected
buildFlexIdentifierList(iterable<string|int, mixed> $collection) : array<string|int, mixed>
Parameters
- $collection : iterable<string|int, mixed>
Return values
array<string|int, mixed>buildMediaList()
protected
buildMediaList(string|null $field) : array<string|int, mixed>
Parameters
- $field : string|null
Return values
array<string|int, mixed>buildMediaObject()
protected
buildMediaObject(string|null $field, string $filename[, MediaObjectInterface|null $image = null ]) : MediaObject|UploadedMediaObject
Parameters
- $field : string|null
- $filename : string
- $image : MediaObjectInterface|null = null
Return values
MediaObject|UploadedMediaObjectcreateFormObject()
This methods allows you to override form objects in child classes.
protected
createFormObject(string $name[, array<string|int, mixed>|null $options = null ]) : FlexFormInterface
Parameters
- $name : string
-
Form name
- $options : array<string|int, mixed>|null = null
-
Form optiosn
Return values
FlexFormInterfacecreateMedium()
protected
createMedium(string $uri) : Medium|null
Parameters
- $uri : string
Return values
Medium|nulldoGetBlueprint()
protected
doGetBlueprint([string $name = '' ]) : Blueprint
Parameters
- $name : string = ''
Return values
BlueprintdoGetProperty()
protected
& doGetProperty(string $property[, mixed $default = null ][, bool $doCreate = false ]) : mixed
Parameters
- $property : string
-
Object property to be fetched.
- $default : mixed = null
-
Default value if property has not been set.
- $doCreate : bool = false
Return values
mixed —Property value.
doHasProperty()
protected
doHasProperty(string $property) : bool
Parameters
- $property : string
-
Object property name.
Return values
bool —True if property has been defined (can be null).
doSerialize()
protected
doSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed>doSetProperty()
protected
doSetProperty(string $property, mixed $value) : void
Parameters
- $property : string
-
Object property to be updated.
- $value : mixed
-
New value.
doUnserialize()
protected
doUnserialize(array<string|int, mixed> $serialized[, FlexDirectory|null $directory = null ]) : void
Parameters
- $serialized : array<string|int, mixed>
- $directory : FlexDirectory|null = null
doUnsetProperty()
protected
doUnsetProperty(string $property) : void
Parameters
- $property : string
-
Object property to be unset.
filterElements()
Filter data coming to constructor or $this->update() request.
protected
filterElements(array<string|int, mixed> &$elements) : void
NOTE: The incoming data can be an arbitrary array so do not assume anything from its content.
Parameters
- $elements : array<string|int, mixed>
freeMedia()
protected
freeMedia() : void
generateMultiavatar()
protected
generateMultiavatar(string $hash) : string
Parameters
- $hash : string
Return values
stringgetAccess()
protected
getAccess() : Access
Return values
AccessgetActiveUser()
protected
getActiveUser() : UserInterface|null
Return values
UserInterface|nullgetAuthorizeAction()
protected
getAuthorizeAction(string $action) : string
Parameters
- $action : string
Return values
stringgetAuthorizeRule()
protected
getAuthorizeRule(string $scope, string $action) : string
Parameters
- $scope : string
- $action : string
Return values
stringgetAuthorizeScope()
protected
getAuthorizeScope() : string
Return values
stringgetAvatarFile()
protected
getAvatarFile() : string|null
Return values
string|nullgetCollectionByProperty()
protected
getCollectionByProperty(string $type, string $property) : FlexCollectionInterface<string|int, FlexObjectInterface>
Parameters
- $type : string
- $property : string
Return values
FlexCollectionInterface<string|int, FlexObjectInterface>getContainer()
protected
getContainer() : Grav
Return values
GravgetElement()
protected
getElement(string $property[, mixed|null $default = null ]) : mixed|null
Parameters
- $property : string
- $default : mixed|null = null
Return values
mixed|nullgetElements()
protected
getElements() : array<string|int, mixed>
Return values
array<string|int, mixed>getFlexContainer()
protected
getFlexContainer() : Flex
Return values
FlexgetGroups()
protected
getGroups() : UserGroupIndex
Return values
UserGroupIndexgetMediaCache()
protected
getMediaCache() : CacheInterface
Return values
CacheInterfacegetMediaFields()
protected
getMediaFields() : array<string|int, mixed>
Return values
array<string|int, mixed>getOriginalMedia()
Gets the associated media collection (original images).
protected
getOriginalMedia() : MediaCollectionInterface
Return values
MediaCollectionInterface —Representation of associated media.
getRelatedDirectory()
protected
getRelatedDirectory(string $type) : FlexDirectory
Parameters
- $type : string
Tags
Return values
FlexDirectorygetStorage()
protected
getStorage() : array<string|int, mixed>
Use ->getMetaData() instead.
Return values
array<string|int, mixed>getTemplate()
protected
getTemplate(string $layout) : Template|TemplateWrapper
Moved to \Grav\Common\Flex\Traits\GravTrait
Parameters
- $layout : string
Tags
Return values
Template|TemplateWrappergetTemplateConfig()
protected
getTemplateConfig() : array<string|int, mixed>
Return values
array<string|int, mixed>getTemplatePaths()
protected
getTemplatePaths(string $layout) : array<string|int, mixed>
Parameters
- $layout : string
Return values
array<string|int, mixed>getTypePrefix()
protected
getTypePrefix() : string
Return values
stringgetUpdatedMedia()
protected
getUpdatedMedia() : array<string, UploadedFileInterface|array<string|int, mixed>|null>
Return values
array<string, UploadedFileInterface|array<string|int, mixed>|null>getUserGroups()
protected
getUserGroups() : UserGroupIndex
Return values
UserGroupIndexisAdminSite()
protected
isAdminSite() : bool
Return values
boolisAuthorizedAction()
Check if user is authorized for the action.
protected
isAuthorizedAction(UserInterface $user, string $action, string $scope, bool $isMe) : bool|null
Parameters
- $user : UserInterface
- $action : string
- $scope : string
- $isMe : bool
Return values
bool|nullisAuthorizedOverride()
protected
isAuthorizedOverride(UserInterface $user, string $action, string $scope[, bool $isMe = false ]) : bool|null
Parameters
- $user : UserInterface
- $action : string
- $scope : string
- $isMe : bool = false
Return values
bool|nullisAuthorizedSuperAdmin()
protected
isAuthorizedSuperAdmin(UserInterface $user) : bool|null
Not needed for Flex Users.
Parameters
- $user : UserInterface
Return values
bool|nullmarkAsCopy()
protected
markAsCopy() : void
offsetLoad_access()
protected
offsetLoad_access(mixed $value) : array<string|int, mixed>
Parameters
- $value : mixed
Return values
array<string|int, mixed>offsetLoad_media()
protected
offsetLoad_media() : MediaCollectionInterface
Return values
MediaCollectionInterfaceoffsetPrepare_access()
protected
offsetPrepare_access(mixed $value) : array<string|int, mixed>
Parameters
- $value : mixed
Return values
array<string|int, mixed>offsetSerialize_access()
protected
offsetSerialize_access(array<string|int, mixed>|null $value) : array<string|int, mixed>|null
Parameters
- $value : array<string|int, mixed>|null
Return values
array<string|int, mixed>|nulloffsetSerialize_media()
protected
offsetSerialize_media() : null
Return values
nullparseFileProperty()
protected
parseFileProperty(array<string|int, mixed>|mixed $value[, array<string|int, mixed> $settings = [] ]) : array<string|int, mixed>|mixed
Parameters
- $value : array<string|int, mixed>|mixed
- $settings : array<string|int, mixed> = []
Return values
array<string|int, mixed>|mixedresetBlueprints()
Method to reset blueprints if the type changes.
protected
resetBlueprints() : void
Tags
resetRelationships()
protected
resetRelationships() : void
saveUpdatedMedia()
protected
saveUpdatedMedia() : void
searchValue()
protected
searchValue(string $name, mixed $value, string $search[, array<string|int, mixed>|null $options = null ]) : float
Parameters
- $name : string
- $value : mixed
- $search : string
- $options : array<string|int, mixed>|null = null
Return values
floatsetKey()
protected
setKey(string $key) : $this
Parameters
- $key : string
Return values
$thissetMetaData()
protected
setMetaData(array<string|int, mixed> $meta) : void
Parameters
- $meta : array<string|int, mixed>
setStorage()
protected
setStorage(array<string|int, mixed> $storage) : void
Use ->setMetaData() instead.
Parameters
- $storage : array<string|int, mixed>
setUpdatedMedia()
protected
setUpdatedMedia(array<string|int, mixed> $files) : void
Parameters
- $files : array<string|int, mixed>
updateAvatarRelationship()
protected
updateAvatarRelationship(ToOneRelationshipInterface $relationship) : void
Parameters
- $relationship : ToOneRelationshipInterface
updateRelationships()
protected
updateRelationships() : bool
Return values
bool —Return true if relationships were updated.