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

Widgets service. More...

Public Member Functions

 getWidgets (int $owner_guid, string $context)
 Get widgets for a particular context. More...
 
 createWidget (int $owner_guid, string $handler, string $context, int $access_id=null)
 Create a new widget instance. More...
 
 canEditLayout (string $context, int $user_guid=0)
 Can the user edit the widget layout. More...
 
 registerType (WidgetDefinition $definition)
 Register a widget type. More...
 
 unregisterType (string $id)
 Remove a widget type. More...
 
 validateType (string $id, string $context=null,\ElggEntity $container=null)
 Checks if a widget type exists for a given id. More...
 
 getAllTypes ()
 Get all widgets. More...
 
 getNameById (string $id, string $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 ( string  $context,
int  $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 145 of file WidgetsService.php.

Elgg\WidgetsService::createWidget ( int  $owner_guid,
string  $handler,
string  $context,
int  $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 106 of file WidgetsService.php.

Elgg\WidgetsService::getAllTypes ( )

Get all widgets.

Returns
[]

Definition at line 226 of file WidgetsService.php.

Elgg\WidgetsService::getNameById ( string  $id,
string  $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|null
Since
2.2.0

Definition at line 241 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 266 of file WidgetsService.php.

Elgg\WidgetsService::getWidgets ( int  $owner_guid,
string  $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
void
See also
elgg_register_widget_type()

Definition at line 178 of file WidgetsService.php.

Elgg\WidgetsService::unregisterType ( string  $id)

Remove a widget type.

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

Definition at line 191 of file WidgetsService.php.

Elgg\WidgetsService::validateType ( string  $id,
string  $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 206 of file WidgetsService.php.


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