Elgg  Version 4.3
Public Member Functions | List of all members
Elgg\WidgetsService Class Reference

Widgets service. More...

Public Member Functions

 getWidgets ($owner_guid, $context)
 Get widgets for a particular context. More...
 
 createWidget ($owner_guid, $handler, $context, $access_id=null)
 Create a new widget instance. More...
 
 canEditLayout ($context, $user_guid=0)
 Can the user edit the widget layout. More...
 
 registerType (WidgetDefinition $definition)
 Register a widget type. More...
 
 unregisterType ($id)
 Remove a widget type. More...
 
 validateType ($id, $context=null,\ElggEntity $container=null)
 Checks if a widget type exists for a given id. More...
 
 getAllTypes ()
 Get all widgets. More...
 
 getNameById ($id, $context= '',\ElggEntity $container=null)
 Returns widget name based on id. More...
 
 getTypes (array $params=[])
 Returns the registered widget types. More...
 

Detailed Description

Widgets service.

Definition at line 13 of file WidgetsService.php.

Member Function Documentation

Elgg\WidgetsService::canEditLayout (   $context,
  $user_guid = 0 
)

Can the user edit the widget layout.

Parameters
string$contextThe widget context
int$user_guidThe GUID of the user (0 for logged in user)
Returns
bool
See also
elgg_can_edit_widget_layout()

Definition at line 146 of file WidgetsService.php.

Elgg\WidgetsService::createWidget (   $owner_guid,
  $handler,
  $context,
  $access_id = null 
)

Create a new widget instance.

Parameters
int$owner_guidGUID of entity that owns this widget
string$handlerThe handler for this widget
string$contextThe context for this widget
int$access_idIf not specified, it is set to the default access level
Returns
int|false Widget GUID or false on failure
See also
elgg_create_widget()

Definition at line 107 of file WidgetsService.php.

Elgg\WidgetsService::getAllTypes ( )

Get all widgets.

Returns
[]

Definition at line 239 of file WidgetsService.php.

Elgg\WidgetsService::getNameById (   $id,
  $context = '',
\ElggEntity  $container = null 
)

Returns widget name based on id.

Parameters
string$idWidget identifier
string$contextContext to check
\ElggEntity$containerOptional limit widget definitions to a container
Returns
string|boolean
Since
2.2.0

Definition at line 254 of file WidgetsService.php.

Elgg\WidgetsService::getTypes ( array  $params = [])

Returns the registered widget types.

Use params to limit the result: [ 'context' => string (defaults to elgg_get_context()), 'container' => (defaults to null) ]

Parameters
array$paramsAssociative array of params used to determine what to return
Returns
[]

Definition at line 278 of file WidgetsService.php.

Elgg\WidgetsService::getWidgets (   $owner_guid,
  $context 
)

Get widgets for a particular context.

The widgets are ordered for display and grouped in columns. $widgets = elgg_get_widgets(elgg_get_logged_in_user_guid(), 'dashboard'); $first_column_widgets = $widgets[1];

Parameters
int$owner_guidThe owner GUID of the layout
string$contextThe context (profile, dashboard, etc)
Returns
[] An 2D array of objects
See also
elgg_get_widgets()

Definition at line 40 of file WidgetsService.php.

Elgg\WidgetsService::registerType ( WidgetDefinition  $definition)

Register a widget type.

Parameters
WidgetDefinition$definitionDefinition of the widget
Returns
bool
See also
elgg_register_widget_type()

Definition at line 179 of file WidgetsService.php.

Elgg\WidgetsService::unregisterType (   $id)

Remove a widget type.

Parameters
string$idThe identifier for the widget
Returns
bool
See also
elgg_unregister_widget_type()

Definition at line 199 of file WidgetsService.php.

Elgg\WidgetsService::validateType (   $id,
  $context = null,
\ElggEntity  $container = null 
)

Checks if a widget type exists for a given id.

Parameters
string$idWidget identifier
string$contextOptional context to check
\ElggEntity$containerOptional limit widget definitions to a container
Returns
bool
See also
elgg_is_widget_type()

Definition at line 219 of file WidgetsService.php.


The documentation for this class was generated from the following file: