From bb5ba73febceb22394e36252dbc44edaf7814ef4 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Fri, 22 Apr 2022 09:30:21 +0200 Subject: [PATCH] Move module related methods from trait to `Dashlet` --- .../Web/Dashboard/Common/ModuleDashlet.php | 70 ------------------- library/Icinga/Web/Dashboard/Dashlet.php | 65 ++++++++++++++++- 2 files changed, 62 insertions(+), 73 deletions(-) delete mode 100644 library/Icinga/Web/Dashboard/Common/ModuleDashlet.php diff --git a/library/Icinga/Web/Dashboard/Common/ModuleDashlet.php b/library/Icinga/Web/Dashboard/Common/ModuleDashlet.php deleted file mode 100644 index 3eed50201..000000000 --- a/library/Icinga/Web/Dashboard/Common/ModuleDashlet.php +++ /dev/null @@ -1,70 +0,0 @@ -module; - } - - /** - * Set the name of the module which provides this dashlet - * - * @param string $module - * - * @return $this - */ - public function setModule(string $module): self - { - $this->module = $module; - - return $this; - } - - /** - * Get whether this widget originates from a module - * - * @return bool - */ - public function isModuleDashlet(): bool - { - return $this->moduleDashlet; - } - - /** - * Set whether this dashlet widget is provided by a module - * - * @param bool $moduleDashlet - * - * @return $this - */ - public function setModuleDashlet(bool $moduleDashlet): self - { - $this->moduleDashlet = $moduleDashlet; - - return $this; - } -} diff --git a/library/Icinga/Web/Dashboard/Dashlet.php b/library/Icinga/Web/Dashboard/Dashlet.php index 2c9eb54a9..bede56e0d 100644 --- a/library/Icinga/Web/Dashboard/Dashlet.php +++ b/library/Icinga/Web/Dashboard/Dashlet.php @@ -6,7 +6,6 @@ namespace Icinga\Web\Dashboard; use Icinga\Application\Icinga; use Icinga\Web\Dashboard\Common\BaseDashboard; -use Icinga\Web\Dashboard\Common\ModuleDashlet; use Icinga\Web\Request; use Icinga\Web\Url; use ipl\Html\BaseHtmlElement; @@ -20,8 +19,6 @@ use ipl\Web\Widget\Link; */ class Dashlet extends BaseDashboard { - use ModuleDashlet; - /** @var string Database table name */ const TABLE = 'icingaweb_dashlet'; @@ -46,6 +43,20 @@ class Dashlet extends BaseDashboard */ protected $progressLabel; + /** + * A flag to identify whether this dashlet widget originates from a module + * + * @var bool + */ + protected $moduleDashlet = false; + + /** + * The name of the module this dashlet comes from + * + * @var string + */ + protected $module; + /** * Create a new dashlet displaying the given url in the provided pane * @@ -145,6 +156,54 @@ class Dashlet extends BaseDashboard return $this->pane; } + /** + * Get the name of the module which provides this dashlet + * + * @return ?string + */ + public function getModule() + { + return $this->module; + } + + /** + * Set the name of the module which provides this dashlet + * + * @param string $module + * + * @return $this + */ + public function setModule(string $module): self + { + $this->module = $module; + + return $this; + } + + /** + * Get whether this widget originates from a module + * + * @return bool + */ + public function isModuleDashlet(): bool + { + return $this->moduleDashlet; + } + + /** + * Set whether this dashlet widget is provided by a module + * + * @param bool $moduleDashlet + * + * @return $this + */ + public function setModuleDashlet(bool $moduleDashlet): self + { + $this->moduleDashlet = $moduleDashlet; + + return $this; + } + /** * Generate a html widget for this dashlet *