Skip to content

Widget Instances

Currently available in beta

Admin Dashboard is currently available in beta, which means some of the features, specifications, and details provided herein are subject to change. We recommend checking back regularly for the most up-to-date information and viewing our roadmap in regard to the general availability release.

When an admin user adds a widget to their dashboard, a widget instance is created. Widget instances are associated with a particular admin user, are stored in the hyva_admin_dashboard_widget_instance table and each instance object implements Hyva\AdminDashboardFramework\Model\WidgetInstance\WidgetInstanceInterface. The Hyva\AdminDashboardFramework\Model\WidgetInstance\WidgetInstance class extends from Magento's AbstractModel and is the concrete implementation of the WidgetInstanceInterface.

Widget Instance Interface Reference

The WidgetInstanceInterface provides getter and setter functions for the values stored in each of the hyva_admin_dashboard_widget_instance table's columns (e.g. getInstanceId(), setConfiguration(array $config) etc.) as well as the following utility functions:

getConfigurationJson()

public function getConfigurationJson(): ?string

This function returns the raw JSON string representing the widget instance configuration, whereas the "default" getConfiguration() function returns the instance configuration as an associative array.

getConfigurablePropertyValues()

public function getConfigurablePropertyValues(): array

This function returns an associative array containing only the configurable property values for the widget instance. An empty array is returned when no configurable property values exist.

getConfigurablePropertyValue()

public function getConfigurablePropertyValue(string $name): mixed

This function returns a single configurable property value. It uses the $name argument to perform the necessary lookup, returning the corresponding value when the $name matches a configurable property name or null otherwise.

getDisplayPropertyValues()

public function getDisplayPropertyValues(): array

This function returns an associative array containing only the display property values for the widget instance. An empty array is returned when no display property values exist.

getDisplayPropertyValue()

public function getDisplayPropertyValue(string $name): mixed

This function returns a single display property value. It uses the $name argument to perform the necessary lookup, returning the corresponding value when the $name matches a display property name or null otherwise.

getDisplayData()

public function getDisplayData(): mixed

This function acts as a proxy for the getDisplayData() function of the widget instance's associated widget type - removing the need for developers to access the widget type object directly.

getWidgetType()

public function getWidgetType(): ?WidgetTypeInterface

This function provides access to the widget instance's associated widget type object.