Fix some signature inconsistencies

This commit is contained in:
Yonas Habteab 2022-05-20 14:01:58 +02:00
parent 7800c699b7
commit 0ad7fdca53
7 changed files with 17 additions and 19 deletions

View File

@ -185,7 +185,7 @@ class DashletManager
* *
* @param Dashlet $dashlet * @param Dashlet $dashlet
* *
* @return void * @return bool
*/ */
public static function ensureItIsNotOrphaned(Dashlet $dashlet): bool public static function ensureItIsNotOrphaned(Dashlet $dashlet): bool
{ {

View File

@ -64,7 +64,6 @@ trait Database
$insert->values(array_combine($insert->getColumns(), $values)); $insert->values(array_combine($insert->getColumns(), $values));
}); });
} }
return $conn; return $conn;

View File

@ -286,11 +286,11 @@ abstract class BaseDashboard implements DashboardEntry
{ {
} }
public function manageEntry($entry, BaseDashboard $origin = null, bool $manageRecursive = false) public function manageEntry($entryOrEntries, BaseDashboard $origin = null, bool $manageRecursive = false)
{ {
} }
public function loadDashboardEntries(string $name = '') public function loadDashboardEntries(string $name = null)
{ {
} }

View File

@ -105,14 +105,14 @@ interface DashboardEntry
* move pane(s)|dashlet(s) from another to this widget you have to also provide the origin from which the * move pane(s)|dashlet(s) from another to this widget you have to also provide the origin from which the
* given entry(ies) originated * given entry(ies) originated
* *
* @param BaseDashboard|BaseDashboard[] $entry The actual dashboard entry to be managed * @param BaseDashboard|BaseDashboard[] $entryOrEntries The actual dashboard entry to be managed
* @param ?BaseDashboard $origin The original widget from which the given entry originates * @param ?BaseDashboard $origin The original widget from which the given entry originates
* @param bool $manageRecursive Whether the given entry should be managed recursively e.g if the given entry * @param bool $manageRecursive Whether the given entry should be managed recursively e.g if the given entry
* is a Pane type, all its dashlets can be managed recursively * is a {@see Pane} type, all its dashlets can be managed recursively
* *
* @return $this * @return $this
*/ */
public function manageEntry($entry, BaseDashboard $origin = null, bool $manageRecursive = false); public function manageEntry($entryOrEntries, BaseDashboard $origin = null, bool $manageRecursive = false);
/** /**
* Load all the assigned entries to this widget * Load all the assigned entries to this widget
@ -121,7 +121,7 @@ interface DashboardEntry
* *
* @return $this * @return $this
*/ */
public function loadDashboardEntries(string $name = ''); public function loadDashboardEntries(string $name = null);
/** /**
* Reset the current position of the internal dashboard entries pointer * Reset the current position of the internal dashboard entries pointer

View File

@ -72,7 +72,7 @@ trait DashboardManager
return sha1($name, true); return sha1($name, true);
} }
public function loadDashboardEntries(string $name = '') public function loadDashboardEntries(string $name = null)
{ {
$home = $this->getEntry($name); $home = $this->getEntry($name);
$home->loadDashboardEntries(); $home->loadDashboardEntries();
@ -137,10 +137,10 @@ trait DashboardManager
return $this; return $this;
} }
public function manageEntry($entry, BaseDashboard $origin = null, $manageRecursive = false) public function manageEntry($entryOrEntries, BaseDashboard $origin = null, $manageRecursive = false)
{ {
$conn = DBUtils::getConn(); $conn = DBUtils::getConn();
$homes = is_array($entry) ? $entry : [$entry]; $homes = is_array($entryOrEntries) ? $entryOrEntries : [$entryOrEntries];
/** @var DashboardHome $home */ /** @var DashboardHome $home */
foreach ($homes as $home) { foreach ($homes as $home) {

View File

@ -136,7 +136,7 @@ class DashboardHome extends BaseDashboard implements Sortable
return $this; return $this;
} }
public function loadDashboardEntries(string $name = '') public function loadDashboardEntries(string $name = null)
{ {
$this->setEntries([]); $this->setEntries([]);
$panes = \Icinga\Model\Pane::on(DBUtils::getConn())->utilize(self::TABLE); $panes = \Icinga\Model\Pane::on(DBUtils::getConn())->utilize(self::TABLE);
@ -172,12 +172,12 @@ class DashboardHome extends BaseDashboard implements Sortable
return $this; return $this;
} }
public function manageEntry($entry, BaseDashboard $origin = null, bool $manageRecursive = false) public function manageEntry($entryOrEntries, BaseDashboard $origin = null, bool $manageRecursive = false)
{ {
$user = Dashboard::getUser(); $user = Dashboard::getUser();
$conn = DBUtils::getConn(); $conn = DBUtils::getConn();
$panes = is_array($entry) ? $entry : [$entry]; $panes = is_array($entryOrEntries) ? $entryOrEntries : [$entryOrEntries];
// Highest priority is 0, so count($entries) are all always lowest prio + 1 // Highest priority is 0, so count($entries) are all always lowest prio + 1
$order = count($this->getEntries()); $order = count($this->getEntries());

View File

@ -89,7 +89,7 @@ class Pane extends BaseDashboard implements Sortable
return $this; return $this;
} }
public function loadDashboardEntries(string $name = '') public function loadDashboardEntries(string $name = null)
{ {
$dashlets = Model\Dashlet::on(DBUtils::getConn()) $dashlets = Model\Dashlet::on(DBUtils::getConn())
->utilize(self::TABLE) ->utilize(self::TABLE)
@ -117,8 +117,7 @@ class Pane extends BaseDashboard implements Sortable
$this->addEntry($newDashlet); $this->addEntry($newDashlet);
if ( if (Modules\DashletManager::isOrphaned($newDashlet)
Modules\DashletManager::isOrphaned($newDashlet)
|| ( || (
$newDashlet->isModuleDashlet() $newDashlet->isModuleDashlet()
&& $dashlet->system_module_dashlet_id === null && $dashlet->system_module_dashlet_id === null
@ -149,7 +148,7 @@ class Pane extends BaseDashboard implements Sortable
return $this; return $this;
} }
public function manageEntry($entry, BaseDashboard $origin = null, bool $manageRecursive = false) public function manageEntry($entryOrEntries, BaseDashboard $origin = null, bool $manageRecursive = false)
{ {
if ($origin && ! $origin instanceof Pane) { if ($origin && ! $origin instanceof Pane) {
throw new \InvalidArgumentException(sprintf( throw new \InvalidArgumentException(sprintf(
@ -169,7 +168,7 @@ class Pane extends BaseDashboard implements Sortable
$user = Dashboard::getUser()->getUsername(); $user = Dashboard::getUser()->getUsername();
$conn = DBUtils::getConn(); $conn = DBUtils::getConn();
$dashlets = is_array($entry) ? $entry : [$entry]; $dashlets = is_array($entryOrEntries) ? $entryOrEntries : [$entryOrEntries];
// Highest priority is 0, so count($entries) are always lowest prio + 1 // Highest priority is 0, so count($entries) are always lowest prio + 1
$order = count($this->getEntries()); $order = count($this->getEntries());
foreach ($dashlets as $dashlet) { foreach ($dashlets as $dashlet) {