Documentation

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

$authorizeCallable

public static Closure|null $authorizeCallable

$isAuthorizedCallable

public static Closure|null $isAuthorizedCallable

$_original

protected array<string|int, mixed>|null $_original

$_storage

protected FileInterface|null $_storage

$_uploads_original

protected array<string|int, mixed>|null $_uploads_original

$access

protected array<string|int, mixed>|null $access

$storage_timestamp

protected int|null $storage_timestamp

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
bool

authorise()

Checks user authorization to the action.

public authorise(string $action) : bool

Use ->authorize() method instead.

Ensures backwards compatibility

Parameters
$action : string
Return values
bool

authorize()

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|null

avatarUrl()

Return the User's avatar URL

public avatarUrl() : string

Use ->getAvatarUrl() method instead.

Return values
string

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
int

create()

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
see
FlexObjectInterface::create()
Return values
static

createFromStorage()

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
static

def()

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
example

$data->def('this.is.my.nested.variable', 'default');

Return values
$this

defNestedProperty()

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
throws
RuntimeException
Return values
$this

defProperty()

public defProperty(string $property, mixed $default) : $this
Parameters
$property : string

Object property to be defined.

$default : mixed

Default value.

Return values
$this

exists()

Returns true if the object exists in the storage.

public exists() : bool
Tags
see
FlexObjectInterface::exists()
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|null

filter()

Filter all items by using blueprints.

public filter() : $this
Return values
$this

get()

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
example

$value = $this->get('this.is.my.nested.variable');

Return values
mixed

Value.

getAvatarUrl()

Return the User's avatar URL

public getAvatarUrl() : string
Return values
string

getBlueprint()

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
see
FlexObjectInterface::getBlueprint()
Return values
Blueprint

Returns a Blueprint.

getCacheChecksum()

Get cache checksum for the object / collection.

public getCacheChecksum() : string
Tags
see
FlexObjectInterface::getCacheChecksum()
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
see
FlexObjectInterface::getCacheKey()
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
string

getDefaults()

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
see
FlexObjectInterface::getDefaultValue()
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>|null

getFlexFeatures()

Get full list of features the object / collection implements.

public getFlexFeatures() : array<string|int, mixed>
Tags
see
FlexCommonInterface::hasFlexFeature()
Return values
array<string|int, mixed>

getFlexType()

Get Flex Type of the object / collection.

public getFlexType() : string
Tags
see
FlexObjectInterface::getFlexType()
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
see
FlexObjectInterface::getForm()
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
see
FlexObjectInterface::getFormValue()
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
throws
RuntimeException
Return values
array<string|int, mixed>

getKey()

public getKey() : string
Tags
see
ObjectInterface::getFlexKey()
Return values
string

getMediaFolder()

Get filesystem path to the associated media.

public getMediaFolder() : string|null
Return values
string|null

getMetaData()

Get index data associated to the object.

public getMetaData() : array<string|int, mixed>
Tags
see
FlexObjectInterface::getMetaData()
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

getStorageFolder()

public getStorageFolder() : string|null
Return values
string|null

getStorageKey()

public abstract getStorageKey() : string
Return values
string

getTimestamp()

Get last updated timestamp for the object / collection.

public getTimestamp() : int
Tags
see
FlexObjectInterface::getTimestamp()
Return values
int

Returns Unix timestamp.

getType()

public getType([bool $prefix = false ]) : string

Use ->getFlexType() instead.

Parameters
$prefix : bool = false
Return values
string

hasFlexFeature()

Test whether the feature is implemented in the object / collection.

public hasFlexFeature(string $name) : bool
Parameters
$name : string
Tags
see
FlexCommonInterface::hasFlexFeature()
Return values
bool

hasNestedProperty()

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
final
Return values
bool|null

isValid()

public isValid() : bool
Return values
bool

join()

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
throws
RuntimeException
Return values
$this

joinDefaults()

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
$this

jsonSerialize()

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
$this

offsetExists()

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
string

refresh()

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
see
FlexObjectInterface::render()
Return values
ContentBlockInterface|HtmlBlock

Returns HtmlBlock containing the rendered output.

save()

Save user

public save() : static
Return values
static

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
see
FlexObjectInterface::search()
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
float

searchProperty()

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
float

set()

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
example

$data->set('this.is.my.nested.variable', $value);

Return values
$this

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
$this

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
throws
RuntimeException
Return values
$this

setProperty()

public setProperty(string $property, mixed $value) : $this
Parameters
$property : string

Object property to be updated.

$value : mixed

New value.

Return values
$this

setStorageKey()

public setStorageKey([string|null $key = null ]) : $this
Parameters
$key : string|null = null
Return values
$this

setTimestamp()

public setTimestamp([int $timestamp = null ]) : $this
Parameters
$timestamp : int = null
Return values
$this

toArray()

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
string

toYaml()

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
$this

undef()

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
example

$data->undef('this.is.my.nested.variable');

Return values
$this

unsetNestedProperty()

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
throws
RuntimeException
Return values
$this

unsetProperty()

public unsetProperty(string $property) : $this
Parameters
$property : string

Object property to be unset.

Return values
$this

update()

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
see
FlexObjectInterface::update()
Return values
static

validate()

Validate by blueprints.

public validate() : $this
Tags
throws
Exception
Return values
$this

value()

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

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>

createFormObject()

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
FlexFormInterface

doGetProperty()

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>

generateMultiavatar()

protected generateMultiavatar(string $hash) : string
Parameters
$hash : string
Return values
string

getAuthorizeAction()

protected getAuthorizeAction(string $action) : string
Parameters
$action : string
Return values
string

getAuthorizeRule()

protected getAuthorizeRule(string $scope, string $action) : string
Parameters
$scope : string
$action : string
Return values
string

getAuthorizeScope()

protected getAuthorizeScope() : string
Return values
string

getAvatarFile()

protected getAvatarFile() : string|null
Return values
string|null

getElement()

protected getElement(string $property[, mixed|null $default = null ]) : mixed|null
Parameters
$property : string
$default : mixed|null = null
Return values
mixed|null

getElements()

protected getElements() : array<string|int, mixed>
Return values
array<string|int, mixed>

getMediaFields()

protected getMediaFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

getStorage()

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
throws
LoaderError
throws
SyntaxError
Return values
Template|TemplateWrapper

getTemplateConfig()

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
string

getUpdatedMedia()

protected getUpdatedMedia() : array<string, UploadedFileInterface|array<string|int, mixed>|null>
Return values
array<string, UploadedFileInterface|array<string|int, mixed>|null>

isAdminSite()

protected isAdminSite() : bool
Return values
bool

isAuthorizedAction()

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|null

isAuthorizedOverride()

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|null

offsetLoad_access()

protected offsetLoad_access(mixed $value) : array<string|int, mixed>
Parameters
$value : mixed
Return values
array<string|int, mixed>

offsetPrepare_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>|null

offsetSerialize_media()

protected offsetSerialize_media() : null
Return values
null

parseFileProperty()

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>|mixed

resetBlueprints()

Method to reset blueprints if the type changes.

protected resetBlueprints() : void
Tags
since
1.7.18

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
float

setKey()

protected setKey(string $key) : $this
Parameters
$key : string
Return values
$this

setMetaData()

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>

updateRelationships()

protected updateRelationships() : bool
Return values
bool

Return true if relationships were updated.


        
On this page

Search results