mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-26 11:19:14 +02:00
Replace usage of LogicException
with AlreadyExistsException
where applicable
This commit is contained in:
parent
395ae80186
commit
89b95d74bf
@ -32,10 +32,11 @@ CREATE TABLE `icingaweb_dashlet` (
|
|||||||
`label` VARCHAR NOT NULL,
|
`label` VARCHAR NOT NULL,
|
||||||
`url` VARCHAR NOT NULL,
|
`url` VARCHAR NOT NULL,
|
||||||
`priority` tinyint NOT NULL,
|
`priority` tinyint NOT NULL,
|
||||||
`disabled` TEXT CHECK ( disabled IN ('n', 'y') ) DEFAULT 'n',
|
`disabled` TEXT CHECK ( disabled IN ('n', 'y') ) DEFAULT 'n',
|
||||||
FOREIGN KEY (`dashboard_id`) REFERENCES `icingaweb_dashboard` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
FOREIGN KEY (`dashboard_id`) REFERENCES `icingaweb_dashboard` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- TODO: Remove me once we have decoupled module dashlets (as a daemon job) from the actual dashboards loading action!!
|
||||||
CREATE TABLE `icingaweb_module_dashlet` (
|
CREATE TABLE `icingaweb_module_dashlet` (
|
||||||
`id` binary(20) NOT NULL PRIMARY KEY,
|
`id` binary(20) NOT NULL PRIMARY KEY,
|
||||||
`name` VARCHAR NOT NULL,
|
`name` VARCHAR NOT NULL,
|
||||||
|
@ -4,9 +4,10 @@
|
|||||||
|
|
||||||
namespace Icinga\Web\Dashboard\Common;
|
namespace Icinga\Web\Dashboard\Common;
|
||||||
|
|
||||||
|
use Icinga\Exception\NotImplementedError;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
|
|
||||||
use Icinga\Web\Dashboard\Dashboard;
|
use Icinga\Web\Dashboard\Dashboard;
|
||||||
|
|
||||||
use function ipl\Stdlib\get_php_type;
|
use function ipl\Stdlib\get_php_type;
|
||||||
|
|
||||||
trait DashboardEntries
|
trait DashboardEntries
|
||||||
@ -82,6 +83,7 @@ trait DashboardEntries
|
|||||||
|
|
||||||
public function createEntry(string $name, $url = null)
|
public function createEntry(string $name, $url = null)
|
||||||
{
|
{
|
||||||
|
throw new NotImplementedError('Not yet implemented by the concrete class!!');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rewindEntries()
|
public function rewindEntries()
|
||||||
|
@ -61,8 +61,8 @@ trait WidgetState
|
|||||||
/**
|
/**
|
||||||
* Get whether this widget is currently being loaded
|
* Get whether this widget is currently being loaded
|
||||||
*
|
*
|
||||||
* This indicates which dashboard tab is currently open if this widget type is a Dashboard Pane
|
* Indicates which dashboard tab is currently open if this widget is a Dashboard Pane type
|
||||||
* or whether the Dashboard Home in the navigation bar is active/focused
|
* or whether the Dashboard Home is active/focused in the navigation bar
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
namespace Icinga\Web\Dashboard;
|
namespace Icinga\Web\Dashboard;
|
||||||
|
|
||||||
|
use Icinga\Exception\AlreadyExistsException;
|
||||||
use Icinga\Exception\Http\HttpNotFoundException;
|
use Icinga\Exception\Http\HttpNotFoundException;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
use Icinga\Model\Home;
|
use Icinga\Model\Home;
|
||||||
@ -244,11 +245,11 @@ class DashboardHome extends BaseDashboard implements Sortable
|
|||||||
} else {
|
} else {
|
||||||
// Failed to move the pane! Should have already been handled by the caller,
|
// Failed to move the pane! Should have already been handled by the caller,
|
||||||
// though I think it's better that we raise an exception here!!
|
// though I think it's better that we raise an exception here!!
|
||||||
throw new \LogicException(sprintf(
|
throw new AlreadyExistsException(
|
||||||
'Dashboard Pane "%s" could not be managed. Dashboard Home "%s" has Pane with the same name!',
|
'Dashboard Pane "%s" could not be managed. Dashboard Home "%s" has Pane with the same name!',
|
||||||
$pane->getTitle(),
|
$pane->getTitle(),
|
||||||
$this->getTitle()
|
$this->getTitle()
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$pane->setHome($this);
|
$pane->setHome($this);
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
namespace Icinga\Web\Dashboard;
|
namespace Icinga\Web\Dashboard;
|
||||||
|
|
||||||
use Icinga\Application\Modules;
|
use Icinga\Application\Modules;
|
||||||
|
use Icinga\Exception\AlreadyExistsException;
|
||||||
use Icinga\Web\Dashboard\Common\BaseDashboard;
|
use Icinga\Web\Dashboard\Common\BaseDashboard;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
@ -238,11 +239,11 @@ class Pane extends BaseDashboard implements Sortable
|
|||||||
} else {
|
} else {
|
||||||
// Failed to move the pane! Should have already been handled by the caller,
|
// Failed to move the pane! Should have already been handled by the caller,
|
||||||
// though I think it's better that we raise an exception here!!
|
// though I think it's better that we raise an exception here!!
|
||||||
throw new \LogicException(sprintf(
|
throw new AlreadyExistsException(
|
||||||
'Dashlet "%s" could not be managed. Dashboard Pane "%s" has a Dashlet with the same name!',
|
'Dashlet "%s" could not be managed. Dashboard Pane "%s" has a Dashlet with the same name!',
|
||||||
$dashlet->getTitle(),
|
$dashlet->getTitle(),
|
||||||
$this->getTitle()
|
$this->getTitle()
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$dashlet->setPane($this);
|
$dashlet->setPane($this);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
namespace Tests\Icinga\Web\Dashboard;
|
namespace Tests\Icinga\Web\Dashboard;
|
||||||
|
|
||||||
|
use Icinga\Exception\AlreadyExistsException;
|
||||||
use Icinga\Test\BaseDashboardTestCase;
|
use Icinga\Test\BaseDashboardTestCase;
|
||||||
use Icinga\Web\Dashboard\Dashlet;
|
use Icinga\Web\Dashboard\Dashlet;
|
||||||
use Icinga\Web\Dashboard\Pane;
|
use Icinga\Web\Dashboard\Pane;
|
||||||
@ -169,7 +170,7 @@ class DashletTest extends BaseDashboardTestCase
|
|||||||
|
|
||||||
public function testWhetherManageEntryThrowsAnExceptionOnDuplicatedError()
|
public function testWhetherManageEntryThrowsAnExceptionOnDuplicatedError()
|
||||||
{
|
{
|
||||||
$this->expectException(\LogicException::class);
|
$this->expectException(AlreadyExistsException::class);
|
||||||
|
|
||||||
$default = $this->getTestHome();
|
$default = $this->getTestHome();
|
||||||
$this->dashboard->manageEntry($default);
|
$this->dashboard->manageEntry($default);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
namespace Tests\Icinga\Web\Dashboard;
|
namespace Tests\Icinga\Web\Dashboard;
|
||||||
|
|
||||||
|
use Icinga\Exception\AlreadyExistsException;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
use Icinga\Test\BaseDashboardTestCase;
|
use Icinga\Test\BaseDashboardTestCase;
|
||||||
use Icinga\Web\Dashboard\DashboardHome;
|
use Icinga\Web\Dashboard\DashboardHome;
|
||||||
@ -176,7 +177,7 @@ class PaneTest extends BaseDashboardTestCase
|
|||||||
|
|
||||||
public function testWhetherManageEntryThrowsAnExceptionOnDuplicatedError()
|
public function testWhetherManageEntryThrowsAnExceptionOnDuplicatedError()
|
||||||
{
|
{
|
||||||
$this->expectException(\LogicException::class);
|
$this->expectException(AlreadyExistsException::class);
|
||||||
|
|
||||||
$default = $this->getTestHome();
|
$default = $this->getTestHome();
|
||||||
$home = $this->getTestHome('Second Home');
|
$home = $this->getTestHome('Second Home');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user