Elgg  Version 5.1
delete.php
Go to the documentation of this file.
1 <?php
6 $widget_guid = (int) get_input('widget_guid');
7 
9 if (!$widget instanceof \ElggWidget) {
10  return elgg_error_response(elgg_echo('widgets:remove:failure'));
11 }
12 
13 elgg_set_page_owner_guid($widget->getContainerGUID());
14 
15 if (!elgg_can_edit_widget_layout((string) $widget->context)) {
16  return elgg_error_response(elgg_echo('widgets:remove:failure'));
17 }
18 
19 if (!$widget->delete()) {
20  return elgg_error_response(elgg_echo('widgets:remove:failure'));
21 }
22 
23 return elgg_ok_response();
elgg_ok_response($content= '', string|array $message= '', string $forward_url=null, int $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
elgg_can_edit_widget_layout(string $context, int $user_guid=0)
Can the user edit the widget layout.
Definition: widgets.php:50
elgg_set_page_owner_guid(int $guid)
Set the guid of the entity that owns this page.
Definition: pageowner.php:34
$widget
Definition: delete.php:8
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
elgg_error_response(string|array $message= '', string $forward_url=REFERRER, int $status_code=ELGG_HTTP_BAD_REQUEST)
Prepare an error response to be returned by a page or an action handler.
get_entity(int $guid)
Loads and returns an entity object from a guid.
Definition: entities.php:67
$widget_guid
Elgg widget delete action.
Definition: delete.php:6