diff --git a/src/Dashboard/Grid.php b/src/Dashboard/Grid.php index 61c72174..e707d4d5 100644 --- a/src/Dashboard/Grid.php +++ b/src/Dashboard/Grid.php @@ -40,9 +40,9 @@ class Grid { - public static function getDashboardCards(): array + public static function getDashboardCards(?array $cards = null): array { - $cards = []; + $cards ??= []; // Declare the following cards only if we show / edit the quick report page of the plugin $in_carbon_report_page = self::in_carbon_report_page(); diff --git a/src/Dashboard/Widget.php b/src/Dashboard/Widget.php index b0622e76..f37a3184 100644 --- a/src/Dashboard/Widget.php +++ b/src/Dashboard/Widget.php @@ -47,9 +47,9 @@ class Widget extends GlpiDashboardWidget { - public static function WidgetTypes(): array + public static function WidgetTypes(?array $types = null): array { - $types = [ + $types = array_merge($types ?? [], [ // Informative 'information_video' => [ 'label' => __('Environmental impact information video', 'carbon'), @@ -111,7 +111,7 @@ public static function WidgetTypes(): array 'width' => 6, 'height' => 3, ], - ]; + ]); // Data diagnostic if (in_array(Computer::class, PLUGIN_CARBON_TYPES)) {