render( [layout], [context] ): Block Renders the object.
Parameters:
string)array)Returns:
object) HtmlBlock class containing the outputNOTE: In twig there is a {% render %} tag, which should be used instead of calling the method directly. This will allow JS/CSS assets from the object to work properly.
{% set contact = grav.get('flex').object('gizwsvkyo5xtms2s', 'contacts') %}
{% render contact layout: 'details' with { my_variable: true } %}
use Grav\Common\Grav;
use Grav\Framework\ContentBlock\HtmlBlock;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
/** @var FlexObjectInterface|null $collection */
$object = Grav::instance()->get('flex')->getObject('gizwsvkyo5xtms2s', 'contacts');
if ($object) {
/** @var HtmlBlock $block */
$block = $object->render('details', ['my_variable' => true]);
}
getKey(): string Get key of the object.
Returns:
string Object keyhasKey(): bool Returns true if the object key has been set.
Returns:
true if object has a key, false otherwisegetFlexType(): string Get type of the object.
Returns:
string Flex directory name where the object belongs intohasProperty( property ): bool Returns true if the object property has been defined and has a value (not null).
Parameters:
string)Returns:
true if property has a value, false otherwise.getProperty( property, default ): mixed Returns the value of the object property.
Parameters:
string)Returns:
mixed Value of the propertynull if the property is not defined or has no valuesetProperty( property, value ): Object Set new value to the object property.
Parameters:
string)mixed)Returns:
object) The object for chaining the method callsWARNING: This method modifies the object instance shared between all the collections. If that is not intended, please clone the object before using this method.
defProperty( property, default ): Object Define default value to the object property.
Parameters:
string)mixed)Returns:
object) The object for chaining the method callsWARNING: This method modifies the object instance shared between all the collections. If that is not intended, please clone the object before using this method.
unsetProperty( property ): Object Remove value of the object property.
Parameters:
string)Returns:
object) The object for chaining the method callsWARNING: This method modifies the object instance shared between all the collections. If that is not intended, please clone the object before using this method.
isAuthorized( action, [scope], [user] ): bool | null Check if user is authorized for the action.
Parameters:
string)
create, read, update, delete, liststring)
admin or siteobject)Returns:
true Allow actionfalse Deny actionnull Not set (acts as Deny)Note: There are two deny values: denied (false), not set (null). This allows chaining multiple rules together when the previous rules were not matched.`
getFlexDirectory(): Directory
Returns:
object)getTimestamp(): int Get last modified timestamp for the object.
Returns:
int Timestamp.search(string, [properties], [options] ): float Search a string from the object, returns weight between 0 and 1.
Parameters:
string)array or null)array)
boolboolboolboolReturns:
float Search weight between 0 and 1, used for ordering the results0 Object does not match the searchNote: If you override this function, make sure you return value in range 0...1!
getFlexKey(): string Get a unique key for the object.
Returns:
string Flex key of the objectFlex Keys can be used without knowing the Directory the Object belongs into.
getStorageKey(): string Get a unique storage key (within the directory) which is used for figuring out the filename or database id.
Returns:
string Storage key of the objectexists(): bool Returns true if the object exists in the storage.
Returns:
true Object exists in the storagefalse Object has not been savedupdate( data, files ): Object Updates object in the memory.
Parameters:
array) Nested arrays of properties with their valuesarray) Array of Psr\Http\Message\UploadedFileInterface objectsReturns:
object) The object for chaining the method callsTIP: You need to save the object after calling this method.
create( [key] ): Object Create new object into the storage.
Parameters:
string) Optional keyReturns:
object) Saved objectcreateCopy( [key] ): Object Create a new object from the current one and save it into the storage.
Parameters:
string) Optional keyReturns:
object) Saved objectsave(): Object Save object into the storage.
Returns:
object) Saved objectdelete(): Object Delete object from the storage.
Returns:
object) Deleted objectgetBlueprint( [name] ): Blueprint Returns the blueprint of the object.
Parameters:
string) Optional name for the blueprintReturns:
object)getForm( [name], [options] ): Form Returns a form instance for the object.
Parameters:
string) Optional name for the formarray) Optional options to the formReturns:
object)getDefaultValue( name, [separator] ): mixed Returns default value suitable to be used in a form for the given property.
Parameters:
string) Name of the propertystring) Optional separator character for nested properties, defaults to . (dot)Returns:
mixed Default value of the propertygetDefaultValues(): array Returns default values suitable to be used in a form for the given property.
Returns:
array All default valuesgetFormValue( name, [default], [separator] ): mixed Returns raw value suitable to be used in a form for the given property.
Parameters:
string) Name of the propertymixed) Optional default value of the field, null if not givenstring) Optional separator character for nested properties, defaults to . (dot)Returns:
mixed Value of the form fieldtriggerEvent( name, [Event] ): Object Trigger an event of your choice.
Parameters:
string) Name of the eventobject) Optional event classReturns:
object) The object for chaining the method callsFound errors? Think you can improve this documentation? Simply click the Edit link at the top of the page, and then the icon on Github to make your changes.
Powered by Grav + with by Trilby Media.