Move module related methods from trait to Dashlet

This commit is contained in:
Yonas Habteab 2022-04-22 09:30:21 +02:00
parent 871e1f7191
commit bb5ba73feb
2 changed files with 62 additions and 73 deletions

View File

@ -1,70 +0,0 @@
<?php
/* Icinga Web 2 | (c) 2022 Icinga GmbH | GPLv2+ */
namespace Icinga\Web\Dashboard\Common;
trait ModuleDashlet
{
/**
* A flag to identify whether this dashlet widget originates from a module
*
* @var bool
*/
private $moduleDashlet = false;
/**
* The name of the module this dashlet comes from
*
* @var string
*/
private $module;
/**
* 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;
}
}

View File

@ -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
*