Backend\Classes\WidgetManager

Source: ~/modules/backend/classes/WidgetManager.php

Widget manager

Protected properties

protected array $formWidgets

An array of form widgets. Stored in the form of ['FormWidgetClass' => $formWidgetInfo].

protected array $formWidgetCallbacks

Cache of form widget registration callbacks.

protected array $formWidgetHints

An array of form widgets keyed by their code. Stored in the form of ['formwidgetcode' => 'FormWidgetClass'].

protected array $reportWidgets

An array of report widgets.

protected array $reportWidgetCallbacks

Cache of report widget registration callbacks.

protected System\Classes\PluginManager $pluginManager

protected static $instance

Public methods

public void __clone()

public void __wakeup()

public static void forgetInstance()

Forget this singleton's instance if it exists

public static void instance()

Create a new instance of this singleton.

public array listFormWidgets()

Returns a list of registered form widgets.

public array listReportWidgets()

Returns a list of registered report widgets.

public void registerFormWidget(string $className, array $widgetInfo=NULL)

Registers a single form widget.

Parameters
  • string $className - Widget class name.
  • array $widgetInfo - Registration information, can contain a code key.

public void registerFormWidgets($definitions)

Manually registers form widget for consideration. Usage:

WidgetManager::registerFormWidgets(function($manager){
    $manager->registerFormWidget('Backend\FormWidgets\CodeEditor', 'codeeditor');
});
Parameters
  • $definitions

public void registerReportWidget($className, $widgetInfo)
Parameters
  • $className
  • $widgetInfo

public void registerReportWidgets($definitions)

Manually registers report widget for consideration. Usage:

WidgetManager::registerReportWidgets(function($manager){
    $manager->registerReportWidget('RainLab\GoogleAnalytics\ReportWidgets\TrafficOverview', [
        'name' => 'Google Analytics traffic overview',
        'context' => 'dashboard'
    ]);
});
Parameters
  • $definitions

public void removeReportWidget(string $className)

Remove a registered ReportWidget.

Parameters
  • string $className - Widget class name.

public string resolveFormWidget(string $name)

Returns a class name from a form widget code Normalizes a class name or converts an code to its class name.

Parameters
  • string $name - Class name or form widget code.

Protected methods

protected void __construct()

Constructor.

protected void init()

Initialize this singleton.