FlexObjectInterface
extends
FlexCommonInterface, NestedObjectInterface, ArrayAccess
in
Defines Flex Objects.
Tags
Table of Contents
Methods
- __construct() : mixed
- Construct a new Flex Object instance.
- create() : static
- Create new object into the storage.
- defNestedProperty() : $this
- defProperty() : $this
- delete() : static
- Delete object from the storage.
- exists() : bool
- Returns true if the object exists in the storage.
- getBlueprint() : Blueprint
- Returns the blueprint of the object.
- getCacheChecksum() : string
- Get cache checksum for the object / collection.
- getCacheKey() : string
- Get a cache key which is used for caching the object / collection.
- 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.
- getFlexDirectory() : FlexDirectory
- Get Flex Directory for the object / collection.
- 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.
- getKey() : string
- getMetaData() : array<string|int, mixed>
- Get index data associated to the object.
- getNestedProperty() : mixed|array<string|int, mixed>
- getProperty() : mixed
- getStorageKey() : string
- Get an unique storage key (within the directory) which is used for figuring out the filename or database id.
- 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
- Returns true if object has a key.
- hasNestedProperty() : bool|array<string|int, bool>
- hasProperty() : bool
- prepareStorage() : array<string|int, mixed>
- Prepare object for saving into the storage.
- render() : ContentBlockInterface|HtmlBlock
- Renders the object.
- save() : static
- Save object into the storage.
- search() : float
- Search a string from the object, returns weight between 0 and 1.
- setNestedProperty() : $this
- setProperty() : $this
- unsetNestedProperty() : $this
- unsetProperty() : $this
- update() : static
- Updates object in the memory.
Methods
__construct()
Construct a new Flex Object instance.
public
__construct(array<string|int, mixed> $elements, string $key, FlexDirectory $directory[, bool $validate = false ]) : mixed
Parameters
- $elements : array<string|int, mixed>
-
Array of object properties.
- $key : string
-
Identifier key for the new object.
- $directory : FlexDirectory
-
Flex Directory the object belongs into.
- $validate : bool = false
-
True if the object should be validated against blueprint.
Tags
create()
Create new object into the storage.
public
create([string|null $key = null ]) : static
Parameters
- $key : string|null = null
-
Optional new key. If key isn't given, random key will be associated to the object.
Tags
Return values
staticdefNestedProperty()
public
defNestedProperty(string $property, mixed $default[, string|null $separator = null ]) : $this
Parameters
- $property : string
-
Object property to be defined.
- $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
Return values
staticexists()
Returns true if the object exists in the storage.
public
exists() : bool
Return values
bool —Returns true if the object exists, false otherwise.
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
Return values
Blueprint —Returns a Blueprint.
getCacheChecksum()
Get cache checksum for the object / collection.
public
getCacheChecksum() : string
If checksum changes, cache gets invalided.
Return values
string —Returns cache checksum.
getCacheKey()
Get a cache key which is used for caching the object / collection.
public
getCacheKey() : string
Return values
string —Returns cache key.
getDefaultValue()
Returns default value suitable to be used in a form for the given property.
public
getDefaultValue(string $name[, string|null $separator = null ]) : mixed|null
Parameters
- $name : string
-
Property name.
- $separator : string|null = 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>
Tags
Return values
array<string|int, mixed> —Returns default values.
getFlexDirectory()
Get Flex Directory for the object / collection.
public
getFlexDirectory() : FlexDirectory
Return values
FlexDirectory —Returns associated Flex Directory.
getFlexFeatures()
Get full list of features the object / collection implements.
public
getFlexFeatures() : array<string|int, mixed>
Return values
array<string|int, mixed>getFlexKey()
Get a unique key for the object.
public
getFlexKey() : string
Flex Keys can be used without knowing the Directory the Object belongs into.
Tags
Return values
string —Returns Flex Key of the object.
getFlexType()
Get Flex Type of the object / collection.
public
getFlexType() : string
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>|null $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 = null
-
Options can be used to further customize the form.
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|null $separator = null ]) : mixed
Parameters
- $name : string
-
Property name.
- $default : mixed = null
-
Default value.
- $separator : string|null = null
-
Optional nested property separator.
Tags
Return values
mixed —Returns value of the field.
getKey()
public
getKey() : string
Return values
stringgetMetaData()
Get index data associated to the object.
public
getMetaData() : array<string|int, mixed>
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|array<string|int, 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|array<string|int, mixed> —Property value.
getProperty()
public
getProperty(string $property[, mixed|null $default = null ]) : mixed
Parameters
- $property : string
-
Object property to be fetched.
- $default : mixed|null = null
-
Default value if property has not been set.
Return values
mixed —Property value.
getStorageKey()
Get an unique storage key (within the directory) which is used for figuring out the filename or database id.
public
getStorageKey() : string
Tags
Return values
string —Returns storage key of the Object.
getTimestamp()
Get last updated timestamp for the object / collection.
public
getTimestamp() : int
Return values
int —Returns Unix timestamp.
getType()
public
getType() : string
Return values
stringhasFlexFeature()
Test whether the feature is implemented in the object / collection.
public
hasFlexFeature(string $name) : bool
Parameters
- $name : string
Return values
boolhasKey()
Returns true if object has a key.
public
hasKey() : bool
Return values
boolhasNestedProperty()
public
hasNestedProperty(string $property[, string|null $separator = null ]) : bool|array<string|int, bool>
Parameters
- $property : string
-
Object property name.
- $separator : string|null = null
-
Separator, defaults to '.'
Return values
bool|array<string|int, 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 (property can be null).
prepareStorage()
Prepare object for saving into the storage.
public
prepareStorage() : array<string|int, mixed>
Return values
array<string|int, mixed> —Returns an array of object properties containing only scalars and arrays.
render()
Renders the object.
public
render([string|null $layout = null ][, array<string|int, mixed> $context = [] ]) : ContentBlockInterface|HtmlBlock
Parameters
- $layout : string|null = 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 object into the storage.
public
save() : static
Tags
Return values
staticsearch()
Search a string from the object, returns weight between 0 and 1.
public
search(string $search[, string|array<string|int, string>|null $properties = null ][, array<string|int, mixed>|null $options = null ]) : float
Note: If you override this function, make sure you return value in range 0...1!
Parameters
- $search : string
-
Search string.
- $properties : string|array<string|int, string>|null = null
-
Properties to search for, defaults to configured properties.
- $options : array<string|int, mixed>|null = null
-
Search options, defaults to configured options.
Tags
Return values
float —Returns a weight between 0 and 1.
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
$thisunsetNestedProperty()
public
unsetNestedProperty(string $property[, string|null $separator = null ]) : $this
Parameters
- $property : string
-
Object property to be unset.
- $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>|array<string|int, UploadedFileInterface> $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>|array<string|int, UploadedFileInterface> = []
-
List of uploaded files to be saved within the object.