Skip to content

Commit bd44197

Browse files
committed
fixed: unable to unset all tracked entity types
1 parent 730bcb1 commit bd44197

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

classes/ColdTrick/EntityViewCounter/Settings.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ class Settings {
1212
*
1313
* @param \Elgg\Event $event 'setting', 'plugin'
1414
*
15-
* @return array
15+
* @return null|string
1616
*/
17-
public static function saveSettingEntityTypes(\Elgg\Event $event) {
18-
17+
public static function saveSettingEntityTypes(\Elgg\Event $event): ?string {
1918
$plugin = $event->getParam('plugin');
2019
if (!$plugin instanceof \ElggPlugin || $plugin->getID() !== 'entity_view_counter') {
21-
return;
20+
return null;
2221
}
2322

24-
if ($event->getParam('name') !== 'entity_types') {
25-
return;
23+
$value = $event->getValue();
24+
if ($event->getParam('name') !== 'entity_types' && !is_array($value)) {
25+
return null;
2626
}
2727

28-
return json_encode($event->getParam('value'));
28+
return json_encode($value);
2929
}
3030
}

views/default/plugins/entity_view_counter/settings.php

+6
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141

4242
$header = elgg_format_element('thead', [], elgg_format_element('tr', [], implode(PHP_EOL, $row)));
4343

44+
// need an empty input in order to be able to unset everything
45+
echo elgg_view_field([
46+
'#type' => 'hidden',
47+
'name' => 'params[entity_types]',
48+
]);
49+
4450
$rows = [];
4551
foreach ($object_types as $subtype) {
4652
$row = [];

0 commit comments

Comments
 (0)