You are here

function hook_fivestar_widgets in Fivestar 8

Same name and namespace in other branches
  1. 7.2 fivestar.api.php \hook_fivestar_widgets()

Hook to provide widgets for the Fivestar module.

This hook is used by Fivestar to define the default widgets, and may be use by other modules to provide additional custom widgets for Fivestar.

Return value

array An associative array of widget definitions. Each element consists of a key formatted as a machine name (ie no spaces, use underscores, etc), and a value which is itself a two element array containing:

  • label: The human-readable name of the widget, for use in the UI.
  • library: The fully-qualified name of the library holding the CSS and images for the widget.

See also

fivestar_fivestar_widgets()

2 functions implement hook_fivestar_widgets()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

fivestar_fivestar_widgets in ./fivestar.module
Implements hook_fivestar_widgets().
fivestar_widget_provider_fivestar_widgets in tests/modules/fivestar_widget_provider/fivestar_widget_provider.module
Implements hook_fivestar_widgets().
3 invocations of hook_fivestar_widgets()
FivestarTestCase::testExposedWidgetDisplay in test/fivestar.field.test
Test that we can switch the fivestar widgets around for the exposed widget type.
fivestar_update_8101 in ./fivestar.install
Updates the Fivestar stars widget settings.
WidgetManager::getWidgets in src/WidgetManager.php
Returns an array of all widgets.

File

./fivestar.api.php, line 24
Provides API documentation for the Fivestar module.

Code

function hook_fivestar_widgets() {

  // Let Fivestar know about my Cool and Awesome Stars.
  $widgets = [
    'awesome' => [
      'library' => 'mymodule/awesome',
      'label' => t('Awesome Stars'),
    ],
    'cool' => [
      'library' => 'mymodule/cool',
      'label' => t('Cool Stars'),
    ],
  ];
  return $widgets;
}