diff --git a/resources/templates/navigation/tree/node.twig b/resources/templates/navigation/tree/node.twig
index 46aec645c8..e9f6251a53 100644
--- a/resources/templates/navigation/tree/node.twig
+++ b/resources/templates/navigation/tree/node.twig
@@ -21,7 +21,7 @@
{% if node.isGroup %}
- {{ get_image(node.icon['image'], node.icon['title']) }}
+ {{ get_image(node.icon.image, node.icon.title) }}
{{ node.name }}
{% else %}
diff --git a/src/Navigation/NavigationTree.php b/src/Navigation/NavigationTree.php
index cb580fe280..c04561fae5 100644
--- a/src/Navigation/NavigationTree.php
+++ b/src/Navigation/NavigationTree.php
@@ -16,6 +16,8 @@ use PhpMyAdmin\Error\ErrorHandler;
use PhpMyAdmin\Favorites\RecentFavoriteTables;
use PhpMyAdmin\Favorites\TableType;
use PhpMyAdmin\Html\Generator;
+use PhpMyAdmin\Navigation\Nodes\Icon;
+use PhpMyAdmin\Navigation\Nodes\Link;
use PhpMyAdmin\Navigation\Nodes\Node;
use PhpMyAdmin\Navigation\Nodes\NodeColumn;
use PhpMyAdmin\Navigation\Nodes\NodeColumnContainer;
@@ -43,7 +45,6 @@ use PhpMyAdmin\UserPrivilegesFactory;
use function __;
use function _ngettext;
-use function array_intersect_key;
use function array_key_exists;
use function array_key_last;
use function array_keys;
@@ -772,7 +773,7 @@ class NavigationTree
$newChild->realName = $child->realName;
$newChild->icon = $child->icon;
- $newChild->links = $child->links;
+ $newChild->link = $child->link;
$newChild->pos2 = $child->pos2;
$newChild->pos3 = $child->pos3;
foreach ($child->children as $elm) {
@@ -802,20 +803,20 @@ class NavigationTree
$groups[$key] = new Node($this->config, (string) $key, NodeType::Container, true);
$groups[$key]->separators = $node->separators;
$groups[$key]->separatorDepth = $node->separatorDepth - 1;
- $groups[$key]->icon = ['image' => 'b_group', 'title' => __('Groups')];
+ $groups[$key]->icon = new Icon(
+ 'b_group',
+ __('Groups'),
+ $node->icon->route,
+ array_merge($node->icon->params, ['tbl_group' => $key]),
+ );
$groups[$key]->pos2 = $node->pos2;
$groups[$key]->pos3 = $node->pos3;
if ($node instanceof NodeTableContainer || $node instanceof NodeViewContainer) {
- $groups[$key]->links = [
- 'text' => [
- 'route' => $node->links['text']['route'],
- 'params' => array_merge($node->links['text']['params'], ['tbl_group' => $key]),
- ],
- 'icon' => [
- 'route' => $node->links['icon']['route'],
- 'params' => array_merge($node->links['icon']['params'], ['tbl_group' => $key]),
- ],
- ];
+ $groups[$key]->link = new Link(
+ '',
+ $node->link->route,
+ array_merge($node->link->params, ['tbl_group' => $key]),
+ );
}
foreach ($newChildren as $newChild) {
@@ -1016,6 +1017,8 @@ class NavigationTree
$paths = $node->getPaths();
$nodeIsContainer = $node->type === NodeType::Container;
$liClasses = '';
+ $iconLinks = [];
+ $textLink = [];
// Whether to show the node in the tree (true for all nodes but root)
// If false, the node's children will still be shown, but as children of the node's parent
@@ -1065,37 +1068,13 @@ class NavigationTree
$args[$parent->urlParamName] = $parent->realName;
}
- $iconLinks = [];
- $iconLinks[] = [
- 'route' => $node->links['icon']['route'],
- 'params' => array_merge(
- $node->links['icon']['params'],
- array_intersect_key($args, $node->links['icon']['params']),
- ),
- 'image' => $node->icon['image'],
- 'title' => $node->icon['title'],
- ];
+ $iconLinks[] = $node->icon->withDifferentParams($args);
- if ($node instanceof NodeTable && isset($node->links['second_icon'], $node->secondIcon)) {
- $iconLinks[] = [
- 'route' => $node->links['second_icon']['route'],
- 'params' => array_merge(
- $node->links['second_icon']['params'],
- array_intersect_key($args, $node->links['second_icon']['params']),
- ),
- 'image' => $node->secondIcon['image'],
- 'title' => $node->secondIcon['title'],
- ];
+ if ($node instanceof NodeTable && $node->secondIcon !== null) {
+ $iconLinks[] = $node->secondIcon->withDifferentParams($args);
}
- $textLink = [
- 'route' => $node->links['text']['route'],
- 'params' => array_merge(
- $node->links['text']['params'],
- array_intersect_key($args, $node->links['text']['params']),
- ),
- 'title' => $node->links['title'] ?? $node->title,
- ];
+ $textLink = $node->link->withDifferentParams($args);
}
$controlButtons .= $node->getHtmlForControlButtons($this->relationParameters->navigationItemsHidingFeature);
@@ -1136,8 +1115,8 @@ class NavigationTree
'node_is_container' => $nodeIsContainer,
'has_second_icon' => isset($node->secondIcon),
'recursive' => ['html' => $recursiveHtml ?? '', 'has_wrapper' => $wrap, 'is_hidden' => ! $node->visible],
- 'icon_links' => $iconLinks ?? [],
- 'text_link' => $textLink ?? [],
+ 'icon_links' => $iconLinks,
+ 'text_link' => $textLink,
'pagination_params' => $paginationParams,
'node_is_group' => $nodeIsGroup ?? false,
'link_classes' => $linkClasses ?? '',
@@ -1180,13 +1159,9 @@ class NavigationTree
}
$paths = $node->getPaths();
- if (! isset($node->links['text'])) {
- continue;
- }
- $title = $node->links['title'] ?? '';
$options[] = [
- 'title' => $title,
+ 'title' => $node->link->title,
'name' => $node->realName,
'data' => ['apath' => $paths['aPath'], 'vpath' => $paths['vPath'], 'pos' => $this->pos],
'isSelected' => $node->realName === $selected,
diff --git a/src/Navigation/Nodes/Icon.php b/src/Navigation/Nodes/Icon.php
new file mode 100644
index 0000000000..b4acc869cf
--- /dev/null
+++ b/src/Navigation/Nodes/Icon.php
@@ -0,0 +1,28 @@
+ $params */
+ public function __construct(
+ public string $image,
+ public string $title,
+ public string $route,
+ public array $params = [],
+ ) {
+ }
+
+ /** @param array $params */
+ public function withDifferentParams(array $params): self
+ {
+ $params = array_merge($this->params, array_intersect_key($params, $this->params));
+
+ return new self($this->image, $this->title, $this->route, $params);
+ }
+}
diff --git a/src/Navigation/Nodes/Link.php b/src/Navigation/Nodes/Link.php
new file mode 100644
index 0000000000..1af25f9c37
--- /dev/null
+++ b/src/Navigation/Nodes/Link.php
@@ -0,0 +1,24 @@
+ $params */
+ public function __construct(public string $title, public string $route, public array $params = [])
+ {
+ }
+
+ /** @param array $params */
+ public function withDifferentParams(array $params): self
+ {
+ $params = array_merge($this->params, array_intersect_key($params, $this->params));
+
+ return new self($this->title, $this->route, $params);
+ }
+}
diff --git a/src/Navigation/Nodes/Node.php b/src/Navigation/Nodes/Node.php
index 3041f162ad..6d93c7770d 100644
--- a/src/Navigation/Nodes/Node.php
+++ b/src/Navigation/Nodes/Node.php
@@ -71,27 +71,11 @@ class Node
/**
* For the IMG tag, used when rendering the node.
- *
- * @var array
- * @psalm-var array{image: string, title: string}
*/
- public array $icon = ['image' => '', 'title' => ''];
+ public Icon $icon;
- /**
- * An array of A tags, used when rendering the node.
- *
- * @var array
- * @psalm-var array{
- * text: array{route: string, params: array},
- * icon: array{route: string, params: array},
- * second_icon?: array{route: string, params: array},
- * title?: string
- * }
- */
- public array $links = ['text' => ['route' => '', 'params' => []], 'icon' => ['route' => '', 'params' => []]];
+ public Link $link;
- /** @var string HTML title */
- public string $title = '';
/** @var string Extra CSS classes for the node */
public string $classes = '';
/** @var bool Whether this node is a link for creating new objects */
@@ -125,6 +109,8 @@ class Node
public bool $isGroup = false,
) {
$this->realName = $name;
+ $this->icon = new Icon('', '', '');
+ $this->link = new Link('', '', []);
}
/**
@@ -138,7 +124,6 @@ class Node
string $classes,
): Node {
$node = new Node($this->config, $name);
- $node->title = $name;
$node->isNew = true;
$node->classes = $classes;
diff --git a/src/Navigation/Nodes/NodeColumn.php b/src/Navigation/Nodes/NodeColumn.php
index 06dbaf76c3..521e8cb7d6 100644
--- a/src/Navigation/Nodes/NodeColumn.php
+++ b/src/Navigation/Nodes/NodeColumn.php
@@ -27,18 +27,17 @@ class NodeColumn extends Node
parent::__construct($config, $item['name']);
- $this->icon = ['image' => $this->getColumnIcon($item['key']), 'title' => __('Column')];
- $this->links = [
- 'text' => [
- 'route' => '/table/structure/change',
- 'params' => ['change_column' => 1, 'db' => null, 'table' => null, 'field' => null],
- ],
- 'icon' => [
- 'route' => '/table/structure/change',
- 'params' => ['change_column' => 1, 'db' => null, 'table' => null, 'field' => null],
- ],
- 'title' => __('Structure'),
- ];
+ $this->icon = new Icon(
+ $this->getColumnIcon($item['key']),
+ __('Column'),
+ '/table/structure/change',
+ ['change_column' => 1, 'db' => null, 'table' => null, 'field' => null],
+ );
+ $this->link = new Link(
+ __('Structure'),
+ '/table/structure/change',
+ ['change_column' => 1, 'db' => null, 'table' => null, 'field' => null],
+ );
$this->urlParamName = 'field';
}
diff --git a/src/Navigation/Nodes/NodeColumnContainer.php b/src/Navigation/Nodes/NodeColumnContainer.php
index 78405bd6a2..b0b130e859 100644
--- a/src/Navigation/Nodes/NodeColumnContainer.php
+++ b/src/Navigation/Nodes/NodeColumnContainer.php
@@ -22,26 +22,27 @@ class NodeColumnContainer extends Node
{
parent::__construct($config, __('Columns'), NodeType::Container);
- $this->icon = ['image' => 'pause', 'title' => __('Columns')];
- $this->links = [
- 'text' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
- 'icon' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
- ];
+ $this->icon = new Icon('pause', __('Columns'), '/table/structure', ['db' => null, 'table' => null]);
+ $this->link = new Link(
+ '',
+ '/table/structure',
+ ['db' => null, 'table' => null],
+ );
$this->realName = 'columns';
$newLabel = _pgettext('Create new column', 'New');
$new = $this->getInstanceForNewNode($newLabel, 'new_column italics');
- $new->icon = ['image' => 'b_column_add', 'title' => $newLabel];
- $new->links = [
- 'text' => [
- 'route' => '/table/add-field',
- 'params' => ['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null],
- ],
- 'icon' => [
- 'route' => '/table/add-field',
- 'params' => ['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null],
- ],
- ];
+ $new->icon = new Icon(
+ 'b_column_add',
+ $newLabel,
+ '/table/add-field',
+ ['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null],
+ );
+ $new->link = new Link(
+ $newLabel,
+ '/table/add-field',
+ ['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null],
+ );
$this->addChild($new);
}
}
diff --git a/src/Navigation/Nodes/NodeDatabase.php b/src/Navigation/Nodes/NodeDatabase.php
index 61794408e5..0bbbf77587 100644
--- a/src/Navigation/Nodes/NodeDatabase.php
+++ b/src/Navigation/Nodes/NodeDatabase.php
@@ -48,16 +48,18 @@ class NodeDatabase extends Node
{
parent::__construct($config, $name);
- $this->icon = ['image' => 's_db', 'title' => __('Database operations')];
+ $this->icon = new Icon(
+ 's_db',
+ __('Database operations'),
+ '/database/operations',
+ ['db' => null],
+ );
- $this->links = [
- 'text' => [
- 'route' => $this->config->settings['DefaultTabDatabase'],
- 'params' => ['db' => null],
- ],
- 'icon' => ['route' => '/database/operations', 'params' => ['db' => null]],
- 'title' => __('Structure'),
- ];
+ $this->link = new Link(
+ __('Structure'),
+ $this->config->settings['DefaultTabDatabase'],
+ ['db' => null],
+ );
$this->classes = 'database';
$this->urlParamName = 'db';
diff --git a/src/Navigation/Nodes/NodeDatabaseContainer.php b/src/Navigation/Nodes/NodeDatabaseContainer.php
index 972ecac65d..b9fa313a9f 100644
--- a/src/Navigation/Nodes/NodeDatabaseContainer.php
+++ b/src/Navigation/Nodes/NodeDatabaseContainer.php
@@ -45,11 +45,8 @@ class NodeDatabaseContainer extends Node
$newLabel = _pgettext('Create new database', 'New');
$new = $this->getInstanceForNewNode($newLabel, 'new_database italics');
- $new->icon = ['image' => 'b_newdb', 'title' => $newLabel];
- $new->links = [
- 'text' => ['route' => '/server/databases', 'params' => []],
- 'icon' => ['route' => '/server/databases', 'params' => []],
- ];
+ $new->icon = new Icon('b_newdb', $newLabel, '/server/databases');
+ $new->link = new Link($newLabel, '/server/databases');
$this->addChild($new);
}
}
diff --git a/src/Navigation/Nodes/NodeEvent.php b/src/Navigation/Nodes/NodeEvent.php
index bc117735df..dedcd56a4d 100644
--- a/src/Navigation/Nodes/NodeEvent.php
+++ b/src/Navigation/Nodes/NodeEvent.php
@@ -21,17 +21,17 @@ class NodeEvent extends NodeDatabaseChild
{
parent::__construct($config, $name);
- $this->icon = ['image' => 'b_events', 'title' => __('Event')];
- $this->links = [
- 'text' => [
- 'route' => '/database/events',
- 'params' => ['edit_item' => 1, 'db' => null, 'item_name' => null],
- ],
- 'icon' => [
- 'route' => '/database/events',
- 'params' => ['export_item' => 1, 'db' => null, 'item_name' => null],
- ],
- ];
+ $this->icon = new Icon(
+ 'b_events',
+ __('Event'),
+ '/database/events',
+ ['edit_item' => 1, 'db' => null, 'item_name' => null],
+ );
+ $this->link = new Link(
+ '',
+ '/database/events',
+ ['edit_item' => 1, 'db' => null, 'item_name' => null],
+ );
$this->classes = 'event';
$this->urlParamName = 'item_name';
}
diff --git a/src/Navigation/Nodes/NodeEventContainer.php b/src/Navigation/Nodes/NodeEventContainer.php
index 5aaeefa316..6c34ca9486 100644
--- a/src/Navigation/Nodes/NodeEventContainer.php
+++ b/src/Navigation/Nodes/NodeEventContainer.php
@@ -21,20 +21,22 @@ class NodeEventContainer extends NodeDatabaseChildContainer
{
parent::__construct($config, __('Events'));
- $this->icon = ['image' => 'b_events', 'title' => __('Events')];
- $this->links = [
- 'text' => ['route' => '/database/events', 'params' => ['db' => null]],
- 'icon' => ['route' => '/database/events', 'params' => ['db' => null]],
- ];
+ $this->icon = new Icon('b_events', __('Events'), '/database/events', ['db' => null]);
+ $this->link = new Link(
+ '',
+ '/database/events',
+ ['db' => null],
+ );
$this->realName = 'events';
$newLabel = _pgettext('Create new event', 'New');
$new = $this->getInstanceForNewNode($newLabel, 'new_event italics');
- $new->icon = ['image' => 'b_event_add', 'title' => $newLabel];
- $new->links = [
- 'text' => ['route' => '/database/events', 'params' => ['add_item' => 1, 'db' => null]],
- 'icon' => ['route' => '/database/events', 'params' => ['add_item' => 1, 'db' => null]],
- ];
+ $new->icon = new Icon('b_event_add', $newLabel, '/database/events', ['add_item' => 1, 'db' => null]);
+ $new->link = new Link(
+ $newLabel,
+ '/database/events',
+ ['add_item' => 1, 'db' => null],
+ );
$this->addChild($new);
}
}
diff --git a/src/Navigation/Nodes/NodeFunction.php b/src/Navigation/Nodes/NodeFunction.php
index b4bab7aabe..bf01088760 100644
--- a/src/Navigation/Nodes/NodeFunction.php
+++ b/src/Navigation/Nodes/NodeFunction.php
@@ -21,17 +21,17 @@ class NodeFunction extends NodeDatabaseChild
{
parent::__construct($config, $name);
- $this->icon = ['image' => 'b_routines', 'title' => __('Function')];
- $this->links = [
- 'text' => [
- 'route' => '/database/routines',
- 'params' => ['item_type' => 'FUNCTION', 'edit_item' => 1, 'db' => null, 'item_name' => null],
- ],
- 'icon' => [
- 'route' => '/database/routines',
- 'params' => ['item_type' => 'FUNCTION', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
- ],
- ];
+ $this->icon = new Icon(
+ 'b_routines',
+ __('Function'),
+ '/database/routines',
+ ['item_type' => 'FUNCTION', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
+ );
+ $this->link = new Link(
+ '',
+ '/database/routines',
+ ['item_type' => 'FUNCTION', 'edit_item' => 1, 'db' => null, 'item_name' => null],
+ );
$this->classes = 'function';
$this->urlParamName = 'item_name';
}
diff --git a/src/Navigation/Nodes/NodeFunctionContainer.php b/src/Navigation/Nodes/NodeFunctionContainer.php
index f5cf09efbc..93d9634163 100644
--- a/src/Navigation/Nodes/NodeFunctionContainer.php
+++ b/src/Navigation/Nodes/NodeFunctionContainer.php
@@ -21,26 +21,32 @@ class NodeFunctionContainer extends NodeDatabaseChildContainer
{
parent::__construct($config, __('Functions'));
- $this->icon = ['image' => 'b_routines', 'title' => __('Functions')];
- $this->links = [
- 'text' => ['route' => '/database/routines', 'params' => ['type' => 'FUNCTION', 'db' => null]],
- 'icon' => ['route' => '/database/routines', 'params' => ['type' => 'FUNCTION', 'db' => null]],
- ];
+ $this->icon = new Icon(
+ 'b_routines',
+ __('Functions'),
+ '/database/routines',
+ ['type' => 'FUNCTION', 'db' => null],
+ );
+ $this->link = new Link(
+ '',
+ '/database/routines',
+ ['type' => 'FUNCTION', 'db' => null],
+ );
$this->realName = 'functions';
$newLabel = _pgettext('Create new function', 'New');
$new = $this->getInstanceForNewNode($newLabel, 'new_function italics');
- $new->icon = ['image' => 'b_routine_add', 'title' => $newLabel];
- $new->links = [
- 'text' => [
- 'route' => '/database/routines',
- 'params' => ['item_type' => 'FUNCTION', 'add_item' => 1, 'db' => null],
- ],
- 'icon' => [
- 'route' => '/database/routines',
- 'params' => ['item_type' => 'FUNCTION', 'add_item' => 1, 'db' => null],
- ],
- ];
+ $new->icon = new Icon(
+ 'b_routine_add',
+ $newLabel,
+ '/database/routines',
+ ['item_type' => 'FUNCTION', 'add_item' => 1, 'db' => null],
+ );
+ $new->link = new Link(
+ $newLabel,
+ '/database/routines',
+ ['item_type' => 'FUNCTION', 'add_item' => 1, 'db' => null],
+ );
$this->addChild($new);
}
}
diff --git a/src/Navigation/Nodes/NodeIndex.php b/src/Navigation/Nodes/NodeIndex.php
index afd83529b1..bcb41c0d62 100644
--- a/src/Navigation/Nodes/NodeIndex.php
+++ b/src/Navigation/Nodes/NodeIndex.php
@@ -21,11 +21,17 @@ class NodeIndex extends Node
{
parent::__construct($config, $name);
- $this->icon = ['image' => 'b_index', 'title' => __('Index')];
- $this->links = [
- 'text' => ['route' => '/table/indexes', 'params' => ['db' => null, 'table' => null, 'index' => null]],
- 'icon' => ['route' => '/table/indexes', 'params' => ['db' => null, 'table' => null, 'index' => null]],
- ];
+ $this->icon = new Icon(
+ 'b_index',
+ __('Index'),
+ '/table/indexes',
+ ['db' => null, 'table' => null, 'index' => null],
+ );
+ $this->link = new Link(
+ '',
+ '/table/indexes',
+ ['db' => null, 'table' => null, 'index' => null],
+ );
$this->classes = 'index';
$this->urlParamName = 'index';
}
diff --git a/src/Navigation/Nodes/NodeIndexContainer.php b/src/Navigation/Nodes/NodeIndexContainer.php
index 82d306716f..68b115d4f7 100644
--- a/src/Navigation/Nodes/NodeIndexContainer.php
+++ b/src/Navigation/Nodes/NodeIndexContainer.php
@@ -22,26 +22,27 @@ class NodeIndexContainer extends Node
{
parent::__construct($config, __('Indexes'), NodeType::Container);
- $this->icon = ['image' => 'b_index', 'title' => __('Indexes')];
- $this->links = [
- 'text' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
- 'icon' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
- ];
+ $this->icon = new Icon('b_index', __('Indexes'), '/table/structure', ['db' => null, 'table' => null]);
+ $this->link = new Link(
+ '',
+ '/table/structure',
+ ['db' => null, 'table' => null],
+ );
$this->realName = 'indexes';
$newLabel = _pgettext('Create new index', 'New');
$new = $this->getInstanceForNewNode($newLabel, 'new_index italics');
- $new->icon = ['image' => 'b_index_add', 'title' => $newLabel];
- $new->links = [
- 'text' => [
- 'route' => '/table/indexes',
- 'params' => ['create_index' => 1, 'added_fields' => 2, 'db' => null, 'table' => null],
- ],
- 'icon' => [
- 'route' => '/table/indexes',
- 'params' => ['create_index' => 1, 'added_fields' => 2, 'db' => null, 'table' => null],
- ],
- ];
+ $new->icon = new Icon(
+ 'b_index_add',
+ $newLabel,
+ '/table/indexes',
+ ['create_index' => 1, 'added_fields' => 2, 'db' => null, 'table' => null],
+ );
+ $new->link = new Link(
+ $newLabel,
+ '/table/indexes',
+ ['create_index' => 1, 'added_fields' => 2, 'db' => null, 'table' => null],
+ );
$this->addChild($new);
}
}
diff --git a/src/Navigation/Nodes/NodeProcedure.php b/src/Navigation/Nodes/NodeProcedure.php
index 5d6f254807..57cf03e306 100644
--- a/src/Navigation/Nodes/NodeProcedure.php
+++ b/src/Navigation/Nodes/NodeProcedure.php
@@ -21,17 +21,17 @@ class NodeProcedure extends NodeDatabaseChild
{
parent::__construct($config, $name);
- $this->icon = ['image' => 'b_routines', 'title' => __('Procedure')];
- $this->links = [
- 'text' => [
- 'route' => '/database/routines',
- 'params' => ['item_type' => 'PROCEDURE', 'edit_item' => 1, 'db' => null, 'item_name' => null],
- ],
- 'icon' => [
- 'route' => '/database/routines',
- 'params' => ['item_type' => 'PROCEDURE', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
- ],
- ];
+ $this->icon = new Icon(
+ 'b_routines',
+ __('Procedure'),
+ '/database/routines',
+ ['item_type' => 'PROCEDURE', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
+ );
+ $this->link = new Link(
+ '',
+ '/database/routines',
+ ['item_type' => 'PROCEDURE', 'edit_item' => 1, 'db' => null, 'item_name' => null],
+ );
$this->classes = 'procedure';
$this->urlParamName = 'item_name';
}
diff --git a/src/Navigation/Nodes/NodeProcedureContainer.php b/src/Navigation/Nodes/NodeProcedureContainer.php
index 8f40385e52..57c1980a31 100644
--- a/src/Navigation/Nodes/NodeProcedureContainer.php
+++ b/src/Navigation/Nodes/NodeProcedureContainer.php
@@ -21,20 +21,32 @@ class NodeProcedureContainer extends NodeDatabaseChildContainer
{
parent::__construct($config, __('Procedures'));
- $this->icon = ['image' => 'b_routines', 'title' => __('Procedures')];
- $this->links = [
- 'text' => ['route' => '/database/routines', 'params' => ['type' => 'PROCEDURE', 'db' => null]],
- 'icon' => ['route' => '/database/routines', 'params' => ['type' => 'PROCEDURE', 'db' => null]],
- ];
+ $this->icon = new Icon(
+ 'b_routines',
+ __('Procedures'),
+ '/database/routines',
+ ['type' => 'PROCEDURE', 'db' => null],
+ );
+ $this->link = new Link(
+ '',
+ '/database/routines',
+ ['type' => 'PROCEDURE', 'db' => null],
+ );
$this->realName = 'procedures';
$newLabel = _pgettext('Create new procedure', 'New');
$new = $this->getInstanceForNewNode($newLabel, 'new_procedure italics');
- $new->icon = ['image' => 'b_routine_add', 'title' => $newLabel];
- $new->links = [
- 'text' => ['route' => '/database/routines', 'params' => ['add_item' => 1, 'db' => null]],
- 'icon' => ['route' => '/database/routines', 'params' => ['add_item' => 1, 'db' => null]],
- ];
+ $new->icon = new Icon(
+ 'b_routine_add',
+ $newLabel,
+ '/database/routines',
+ ['add_item' => 1, 'db' => null],
+ );
+ $new->link = new Link(
+ $newLabel,
+ '/database/routines',
+ ['add_item' => 1, 'db' => null],
+ );
$this->addChild($new);
}
}
diff --git a/src/Navigation/Nodes/NodeTable.php b/src/Navigation/Nodes/NodeTable.php
index 6341de4663..dc5458e61a 100644
--- a/src/Navigation/Nodes/NodeTable.php
+++ b/src/Navigation/Nodes/NodeTable.php
@@ -23,40 +23,32 @@ class NodeTable extends NodeDatabaseChild
{
/**
* For the second IMG tag, used when rendering the node.
- *
- * @var array|null
- * @psalm-var array{image: string, title: string}|null
*/
- public array|null $secondIcon = null;
+ public Icon|null $secondIcon = null;
/** @param string $name An identifier for the new node */
public function __construct(Config $config, string $name)
{
parent::__construct($config, $name);
- $icon = $this->addIcon($this->config->settings['NavigationTreeDefaultTabTable']);
+ $icon = $this->addIcon(
+ $this->config->settings['NavigationTreeDefaultTabTable'],
+ ['db' => null, 'table' => null],
+ );
if ($icon !== null) {
$this->icon = $icon;
}
- $this->secondIcon = $this->addIcon($this->config->settings['NavigationTreeDefaultTabTable2']);
- $this->title = Util::getTitleForTarget($this->config->settings['DefaultTabTable']);
+ $this->secondIcon = $this->addIcon(
+ $this->config->settings['NavigationTreeDefaultTabTable2'],
+ ['db' => null, 'table' => null],
+ );
- $this->links = [
- 'text' => [
- 'route' => $this->config->settings['DefaultTabTable'],
- 'params' => ['pos' => 0, 'db' => null, 'table' => null],
- ],
- 'icon' => [
- 'route' => $this->config->settings['NavigationTreeDefaultTabTable'],
- 'params' => ['db' => null, 'table' => null],
- ],
- 'second_icon' => [
- 'route' => $this->config->settings['NavigationTreeDefaultTabTable2'],
- 'params' => ['db' => null, 'table' => null],
- ],
- 'title' => $this->title,
- ];
+ $this->link = new Link(
+ Util::getTitleForTarget($this->config->settings['DefaultTabTable']),
+ $this->config->settings['DefaultTabTable'],
+ ['pos' => 0, 'db' => null, 'table' => null],
+ );
$this->classes = 'nav_node_table';
$this->urlParamName = 'table';
}
@@ -267,18 +259,17 @@ class NodeTable extends NodeDatabaseChild
/**
* Add an icon to navigation tree
*
- * @param '/table/sql'|'/table/search'|'/table/change'|'/sql'|'/table/structure'|'' $page Page name to redirect
- *
- * @return array{image: string, title: string}|null
+ * @param '/table/sql'|'/table/search'|'/table/change'|'/sql'|'/table/structure'|'' $page Page name to redirect
+ * @param array $params
*/
- private function addIcon(string $page): array|null
+ private function addIcon(string $page, array $params): Icon|null
{
return match ($page) {
- '/table/structure' => ['image' => 'b_props', 'title' => __('Structure')],
- '/table/search' => ['image' => 'b_search', 'title' => __('Search')],
- '/table/change' => ['image' => 'b_insrow', 'title' => __('Insert')],
- '/table/sql' => ['image' => 'b_sql', 'title' => __('SQL')],
- '/sql' => ['image' => 'b_browse', 'title' => __('Browse')],
+ '/table/structure' => new Icon('b_props', __('Structure'), $page, $params),
+ '/table/search' => new Icon('b_search', __('Search'), $page, $params),
+ '/table/change' => new Icon('b_insrow', __('Insert'), $page, $params),
+ '/table/sql' => new Icon('b_sql', __('SQL'), $page, $params),
+ '/sql' => new Icon('b_browse', __('Browse'), $page, $params),
default => null,
};
}
diff --git a/src/Navigation/Nodes/NodeTableContainer.php b/src/Navigation/Nodes/NodeTableContainer.php
index dd9b8ea249..64f2c97795 100644
--- a/src/Navigation/Nodes/NodeTableContainer.php
+++ b/src/Navigation/Nodes/NodeTableContainer.php
@@ -21,21 +21,23 @@ class NodeTableContainer extends NodeDatabaseChildContainer
{
parent::__construct($config, __('Tables'));
- $this->icon = ['image' => 'b_browse', 'title' => __('Tables')];
- $this->links = [
- 'text' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'table', 'db' => null]],
- 'icon' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'table', 'db' => null]],
- ];
+ $this->icon = new Icon('b_browse', __('Tables'), '/database/structure', ['tbl_type' => 'table', 'db' => null]);
+ $this->link = new Link(
+ '',
+ '/database/structure',
+ ['tbl_type' => 'table', 'db' => null],
+ );
$this->realName = 'tables';
$this->classes = 'tableContainer subContainer';
$newLabel = _pgettext('Create new table', 'New');
$new = $this->getInstanceForNewNode($newLabel, 'new_table italics');
- $new->icon = ['image' => 'b_table_add', 'title' => $newLabel];
- $new->links = [
- 'text' => ['route' => '/table/create', 'params' => ['db' => null]],
- 'icon' => ['route' => '/table/create', 'params' => ['db' => null]],
- ];
+ $new->icon = new Icon('b_table_add', $newLabel, '/table/create', ['db' => null]);
+ $new->link = new Link(
+ $newLabel,
+ '/table/create',
+ ['db' => null],
+ );
$this->addChild($new);
}
}
diff --git a/src/Navigation/Nodes/NodeTrigger.php b/src/Navigation/Nodes/NodeTrigger.php
index b91ef5458a..037df74956 100644
--- a/src/Navigation/Nodes/NodeTrigger.php
+++ b/src/Navigation/Nodes/NodeTrigger.php
@@ -21,17 +21,17 @@ class NodeTrigger extends Node
{
parent::__construct($config, $name);
- $this->icon = ['image' => 'b_triggers', 'title' => __('Trigger')];
- $this->links = [
- 'text' => [
- 'route' => '/triggers',
- 'params' => ['edit_item' => 1, 'db' => null, 'item_name' => null],
- ],
- 'icon' => [
- 'route' => '/triggers',
- 'params' => ['export_item' => 1, 'db' => null, 'item_name' => null],
- ],
- ];
+ $this->icon = new Icon(
+ 'b_triggers',
+ __('Trigger'),
+ '/triggers',
+ ['export_item' => 1, 'db' => null, 'item_name' => null],
+ );
+ $this->link = new Link(
+ '',
+ '/triggers',
+ ['edit_item' => 1, 'db' => null, 'item_name' => null],
+ );
$this->classes = 'trigger';
$this->urlParamName = 'item_name';
}
diff --git a/src/Navigation/Nodes/NodeTriggerContainer.php b/src/Navigation/Nodes/NodeTriggerContainer.php
index 953c034615..508de6b952 100644
--- a/src/Navigation/Nodes/NodeTriggerContainer.php
+++ b/src/Navigation/Nodes/NodeTriggerContainer.php
@@ -22,20 +22,22 @@ class NodeTriggerContainer extends Node
{
parent::__construct($config, __('Triggers'), NodeType::Container);
- $this->icon = ['image' => 'b_triggers', 'title' => __('Triggers')];
- $this->links = [
- 'text' => ['route' => '/triggers', 'params' => ['db' => null, 'table' => null]],
- 'icon' => ['route' => '/triggers', 'params' => ['db' => null, 'table' => null]],
- ];
+ $this->icon = new Icon('b_triggers', __('Triggers'), '/triggers', ['db' => null, 'table' => null]);
+ $this->link = new Link(
+ '',
+ '/triggers',
+ ['db' => null, 'table' => null],
+ );
$this->realName = 'triggers';
$newLabel = _pgettext('Create new trigger', 'New');
$new = $this->getInstanceForNewNode($newLabel, 'new_trigger italics');
- $new->icon = ['image' => 'b_trigger_add', 'title' => $newLabel];
- $new->links = [
- 'text' => ['route' => '/triggers', 'params' => ['add_item' => 1, 'db' => null]],
- 'icon' => ['route' => '/triggers', 'params' => ['add_item' => 1, 'db' => null]],
- ];
+ $new->icon = new Icon('b_trigger_add', $newLabel, '/triggers', ['add_item' => 1, 'db' => null]);
+ $new->link = new Link(
+ $newLabel,
+ '/triggers',
+ ['add_item' => 1, 'db' => null],
+ );
$this->addChild($new);
}
}
diff --git a/src/Navigation/Nodes/NodeView.php b/src/Navigation/Nodes/NodeView.php
index 001ba53239..103e420298 100644
--- a/src/Navigation/Nodes/NodeView.php
+++ b/src/Navigation/Nodes/NodeView.php
@@ -21,11 +21,12 @@ class NodeView extends NodeDatabaseChild
{
parent::__construct($config, $name);
- $this->icon = ['image' => 'b_props', 'title' => __('View')];
- $this->links = [
- 'text' => ['route' => '/sql', 'params' => ['pos' => 0, 'db' => null, 'table' => null]],
- 'icon' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
- ];
+ $this->icon = new Icon('b_props', __('View'), '/table/structure', ['db' => null, 'table' => null]);
+ $this->link = new Link(
+ '',
+ '/sql',
+ ['pos' => 0, 'db' => null, 'table' => null],
+ );
$this->classes = 'view';
$this->urlParamName = 'table';
}
diff --git a/src/Navigation/Nodes/NodeViewContainer.php b/src/Navigation/Nodes/NodeViewContainer.php
index 60fdd5a37e..4738622201 100644
--- a/src/Navigation/Nodes/NodeViewContainer.php
+++ b/src/Navigation/Nodes/NodeViewContainer.php
@@ -21,21 +21,23 @@ class NodeViewContainer extends NodeDatabaseChildContainer
{
parent::__construct($config, __('Views'));
- $this->icon = ['image' => 'b_views', 'title' => __('Views')];
- $this->links = [
- 'text' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'view', 'db' => null]],
- 'icon' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'view', 'db' => null]],
- ];
+ $this->icon = new Icon('b_views', __('Views'), '/database/structure', ['tbl_type' => 'view', 'db' => null]);
+ $this->link = new Link(
+ '',
+ '/database/structure',
+ ['tbl_type' => 'view', 'db' => null],
+ );
$this->classes = 'viewContainer subContainer';
$this->realName = 'views';
$newLabel = _pgettext('Create new view', 'New');
$new = $this->getInstanceForNewNode($newLabel, 'new_view italics');
- $new->icon = ['image' => 'b_view_add', 'title' => $newLabel];
- $new->links = [
- 'text' => ['route' => '/view/create', 'params' => ['db' => null]],
- 'icon' => ['route' => '/view/create', 'params' => ['db' => null]],
- ];
+ $new->icon = new Icon('b_view_add', $newLabel, '/view/create', ['db' => null]);
+ $new->link = new Link(
+ $newLabel,
+ '/view/create',
+ ['db' => null],
+ );
$this->addChild($new);
}
}
diff --git a/tests/unit/Navigation/Nodes/NodeColumnContainerTest.php b/tests/unit/Navigation/Nodes/NodeColumnContainerTest.php
index 9e2105f3a4..f014e2c7ea 100644
--- a/tests/unit/Navigation/Nodes/NodeColumnContainerTest.php
+++ b/tests/unit/Navigation/Nodes/NodeColumnContainerTest.php
@@ -19,35 +19,31 @@ final class NodeColumnContainerTest extends AbstractTestCase
self::assertSame('Columns', $nodeColumnContainer->name);
self::assertSame(NodeType::Container, $nodeColumnContainer->type);
self::assertFalse($nodeColumnContainer->isGroup);
- self::assertSame(['image' => 'pause', 'title' => 'Columns'], $nodeColumnContainer->icon);
- self::assertSame(
- [
- 'text' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
- 'icon' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
- ],
- $nodeColumnContainer->links,
- );
+ self::assertSame('pause', $nodeColumnContainer->icon->image);
+ self::assertSame('Columns', $nodeColumnContainer->icon->title);
+ self::assertSame('/table/structure', $nodeColumnContainer->icon->route);
+ self::assertSame(['db' => null, 'table' => null], $nodeColumnContainer->icon->params);
+ self::assertSame('/table/structure', $nodeColumnContainer->link->route);
+ self::assertSame(['db' => null, 'table' => null], $nodeColumnContainer->link->params);
self::assertSame('columns', $nodeColumnContainer->realName);
self::assertCount(1, $nodeColumnContainer->children);
self::assertArrayHasKey(0, $nodeColumnContainer->children);
$newNode = $nodeColumnContainer->children[0];
self::assertSame('New', $newNode->name);
- self::assertSame('New', $newNode->title);
+ self::assertSame('New', $newNode->link->title);
self::assertTrue($newNode->isNew);
self::assertSame('new_column italics', $newNode->classes);
- self::assertSame(['image' => 'b_column_add', 'title' => 'New'], $newNode->icon);
+ self::assertSame('b_column_add', $newNode->icon->image);
+ self::assertSame('/table/add-field', $newNode->icon->route);
+ self::assertSame('New', $newNode->icon->title);
self::assertSame(
- [
- 'text' => [
- 'route' => '/table/add-field',
- 'params' => ['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null],
- ],
- 'icon' => [
- 'route' => '/table/add-field',
- 'params' => ['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null],
- ],
- ],
- $newNode->links,
+ ['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null],
+ $newNode->icon->params,
+ );
+ self::assertSame('/table/add-field', $newNode->link->route);
+ self::assertSame(
+ ['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null],
+ $newNode->link->params,
);
}
}
diff --git a/tests/unit/Navigation/Nodes/NodeColumnTest.php b/tests/unit/Navigation/Nodes/NodeColumnTest.php
index cf62543ae7..3d4afff99f 100644
--- a/tests/unit/Navigation/Nodes/NodeColumnTest.php
+++ b/tests/unit/Navigation/Nodes/NodeColumnTest.php
@@ -26,21 +26,19 @@ final class NodeColumnTest extends AbstractTestCase
self::assertSame(NodeType::Object, $nodeColumn->type);
self::assertFalse($nodeColumn->isGroup);
self::assertSame('actor_id (PRI, smallint)', $nodeColumn->displayName);
- self::assertSame(['image' => 'b_primary', 'title' => 'Column'], $nodeColumn->icon);
+ self::assertSame('b_primary', $nodeColumn->icon->image);
+ self::assertSame('Column', $nodeColumn->icon->title);
+ self::assertSame('/table/structure/change', $nodeColumn->icon->route);
self::assertSame(
- [
- 'text' => [
- 'route' => '/table/structure/change',
- 'params' => ['change_column' => 1, 'db' => null, 'table' => null, 'field' => null],
- ],
- 'icon' => [
- 'route' => '/table/structure/change',
- 'params' => ['change_column' => 1, 'db' => null, 'table' => null, 'field' => null],
- ],
- 'title' => 'Structure',
- ],
- $nodeColumn->links,
+ ['change_column' => 1, 'db' => null, 'table' => null, 'field' => null],
+ $nodeColumn->icon->params,
);
+ self::assertSame('/table/structure/change', $nodeColumn->link->route);
+ self::assertSame(
+ ['change_column' => 1, 'db' => null, 'table' => null, 'field' => null],
+ $nodeColumn->link->params,
+ );
+ self::assertSame('Structure', $nodeColumn->link->title);
self::assertSame('field', $nodeColumn->urlParamName);
}
@@ -54,7 +52,8 @@ final class NodeColumnTest extends AbstractTestCase
'nullable' => '',
]);
self::assertSame('last_update (timestamp, curren...)', $nodeColumn->displayName);
- self::assertSame(['image' => 'pause', 'title' => 'Column'], $nodeColumn->icon);
+ self::assertSame('pause', $nodeColumn->icon->image);
+ self::assertSame('Column', $nodeColumn->icon->title);
}
public function testColumnNodeWithTruncatedDefaultValue2(): void
@@ -67,7 +66,8 @@ final class NodeColumnTest extends AbstractTestCase
'nullable' => 'nullable',
]);
self::assertSame('email (UNI, varchar, defaul..., nullable)', $nodeColumn->displayName);
- self::assertSame(['image' => 'bd_primary', 'title' => 'Column'], $nodeColumn->icon);
+ self::assertSame('bd_primary', $nodeColumn->icon->image);
+ self::assertSame('Column', $nodeColumn->icon->title);
}
public function testColumnNodeWithoutTruncatedDefaultValue(): void
@@ -80,6 +80,7 @@ final class NodeColumnTest extends AbstractTestCase
'nullable' => '',
]);
self::assertSame('email (varchar, column)', $nodeColumn->displayName);
- self::assertSame(['image' => 'pause', 'title' => 'Column'], $nodeColumn->icon);
+ self::assertSame('pause', $nodeColumn->icon->image);
+ self::assertSame('Column', $nodeColumn->icon->title);
}
}
diff --git a/tests/unit/Navigation/Nodes/NodeDatabaseTest.php b/tests/unit/Navigation/Nodes/NodeDatabaseTest.php
index 34fb59bee2..bead4ad662 100644
--- a/tests/unit/Navigation/Nodes/NodeDatabaseTest.php
+++ b/tests/unit/Navigation/Nodes/NodeDatabaseTest.php
@@ -21,14 +21,11 @@ class NodeDatabaseTest extends AbstractTestCase
public function testConstructor(): void
{
$parent = new NodeDatabase(new Config(), 'default');
- self::assertSame(
- [
- 'text' => ['route' => '/database/structure', 'params' => ['db' => null]],
- 'icon' => ['route' => '/database/operations', 'params' => ['db' => null]],
- 'title' => 'Structure',
- ],
- $parent->links,
- );
+ self::assertSame('/database/structure', $parent->link->route);
+ self::assertSame(['db' => null], $parent->link->params);
+ self::assertSame('Structure', $parent->link->title);
+ self::assertSame('/database/operations', $parent->icon->route);
+ self::assertSame(['db' => null], $parent->icon->params);
self::assertStringContainsString('database', $parent->classes);
}
diff --git a/tests/unit/Navigation/Nodes/NodeEventContainerTest.php b/tests/unit/Navigation/Nodes/NodeEventContainerTest.php
index ba3dffdf9f..daa876ff21 100644
--- a/tests/unit/Navigation/Nodes/NodeEventContainerTest.php
+++ b/tests/unit/Navigation/Nodes/NodeEventContainerTest.php
@@ -18,13 +18,10 @@ class NodeEventContainerTest extends AbstractTestCase
public function testConstructor(): void
{
$parent = new NodeEventContainer(new Config());
- self::assertSame(
- [
- 'text' => ['route' => '/database/events', 'params' => ['db' => null]],
- 'icon' => ['route' => '/database/events', 'params' => ['db' => null]],
- ],
- $parent->links,
- );
+ self::assertSame('/database/events', $parent->link->route);
+ self::assertSame(['db' => null], $parent->link->params);
+ self::assertSame('/database/events', $parent->icon->route);
+ self::assertSame(['db' => null], $parent->icon->params);
self::assertSame('events', $parent->realName);
}
}
diff --git a/tests/unit/Navigation/Nodes/NodeEventTest.php b/tests/unit/Navigation/Nodes/NodeEventTest.php
index c21ebd0c49..71f8bb7b43 100644
--- a/tests/unit/Navigation/Nodes/NodeEventTest.php
+++ b/tests/unit/Navigation/Nodes/NodeEventTest.php
@@ -18,18 +18,9 @@ class NodeEventTest extends AbstractTestCase
public function testConstructor(): void
{
$parent = new NodeEvent(new Config(), 'default');
- self::assertSame(
- [
- 'text' => [
- 'route' => '/database/events',
- 'params' => ['edit_item' => 1, 'db' => null, 'item_name' => null],
- ],
- 'icon' => [
- 'route' => '/database/events',
- 'params' => ['export_item' => 1, 'db' => null, 'item_name' => null],
- ],
- ],
- $parent->links,
- );
+ self::assertSame('/database/events', $parent->link->route);
+ self::assertSame(['edit_item' => 1, 'db' => null, 'item_name' => null], $parent->link->params);
+ self::assertSame('/database/events', $parent->icon->route);
+ self::assertSame(['edit_item' => 1, 'db' => null, 'item_name' => null], $parent->icon->params);
}
}
diff --git a/tests/unit/Navigation/Nodes/NodeFunctionContainerTest.php b/tests/unit/Navigation/Nodes/NodeFunctionContainerTest.php
index 784973b6e1..a63a66ca4d 100644
--- a/tests/unit/Navigation/Nodes/NodeFunctionContainerTest.php
+++ b/tests/unit/Navigation/Nodes/NodeFunctionContainerTest.php
@@ -18,13 +18,10 @@ class NodeFunctionContainerTest extends AbstractTestCase
public function testConstructor(): void
{
$parent = new NodeFunctionContainer(new Config());
- self::assertSame(
- [
- 'text' => ['route' => '/database/routines', 'params' => ['type' => 'FUNCTION', 'db' => null]],
- 'icon' => ['route' => '/database/routines', 'params' => ['type' => 'FUNCTION', 'db' => null]],
- ],
- $parent->links,
- );
+ self::assertSame('/database/routines', $parent->link->route);
+ self::assertSame(['type' => 'FUNCTION', 'db' => null], $parent->link->params);
+ self::assertSame('/database/routines', $parent->icon->route);
+ self::assertSame(['type' => 'FUNCTION', 'db' => null], $parent->icon->params);
self::assertSame('functions', $parent->realName);
}
}
diff --git a/tests/unit/Navigation/Nodes/NodeFunctionTest.php b/tests/unit/Navigation/Nodes/NodeFunctionTest.php
index fbf999ce30..82094fbbe7 100644
--- a/tests/unit/Navigation/Nodes/NodeFunctionTest.php
+++ b/tests/unit/Navigation/Nodes/NodeFunctionTest.php
@@ -18,18 +18,15 @@ class NodeFunctionTest extends AbstractTestCase
public function testConstructor(): void
{
$parent = new NodeFunction(new Config(), 'default');
+ self::assertSame('/database/routines', $parent->link->route);
self::assertSame(
- [
- 'text' => [
- 'route' => '/database/routines',
- 'params' => ['item_type' => 'FUNCTION', 'edit_item' => 1, 'db' => null, 'item_name' => null],
- ],
- 'icon' => [
- 'route' => '/database/routines',
- 'params' => ['item_type' => 'FUNCTION', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
- ],
- ],
- $parent->links,
+ ['item_type' => 'FUNCTION', 'edit_item' => 1, 'db' => null, 'item_name' => null],
+ $parent->link->params,
+ );
+ self::assertSame('/database/routines', $parent->icon->route);
+ self::assertSame(
+ ['item_type' => 'FUNCTION', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
+ $parent->icon->params,
);
}
}
diff --git a/tests/unit/Navigation/Nodes/NodeIndexContainerTest.php b/tests/unit/Navigation/Nodes/NodeIndexContainerTest.php
index 76abe373a4..01c2375646 100644
--- a/tests/unit/Navigation/Nodes/NodeIndexContainerTest.php
+++ b/tests/unit/Navigation/Nodes/NodeIndexContainerTest.php
@@ -18,13 +18,10 @@ class NodeIndexContainerTest extends AbstractTestCase
public function testConstructor(): void
{
$parent = new NodeIndexContainer(new Config());
- self::assertSame(
- [
- 'text' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
- 'icon' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
- ],
- $parent->links,
- );
+ self::assertSame('/table/structure', $parent->link->route);
+ self::assertSame(['db' => null, 'table' => null], $parent->link->params);
+ self::assertSame('/table/structure', $parent->icon->route);
+ self::assertSame(['db' => null, 'table' => null], $parent->icon->params);
self::assertSame('indexes', $parent->realName);
}
}
diff --git a/tests/unit/Navigation/Nodes/NodeIndexTest.php b/tests/unit/Navigation/Nodes/NodeIndexTest.php
index 9de815551c..347da11bb9 100644
--- a/tests/unit/Navigation/Nodes/NodeIndexTest.php
+++ b/tests/unit/Navigation/Nodes/NodeIndexTest.php
@@ -18,12 +18,9 @@ class NodeIndexTest extends AbstractTestCase
public function testConstructor(): void
{
$parent = new NodeIndex(new Config(), 'default');
- self::assertSame(
- [
- 'text' => ['route' => '/table/indexes', 'params' => ['db' => null, 'table' => null, 'index' => null]],
- 'icon' => ['route' => '/table/indexes', 'params' => ['db' => null, 'table' => null, 'index' => null]],
- ],
- $parent->links,
- );
+ self::assertSame('/table/indexes', $parent->link->route);
+ self::assertSame(['db' => null, 'table' => null, 'index' => null], $parent->link->params);
+ self::assertSame('/table/indexes', $parent->icon->route);
+ self::assertSame(['db' => null, 'table' => null, 'index' => null], $parent->icon->params);
}
}
diff --git a/tests/unit/Navigation/Nodes/NodeProcedureContainerTest.php b/tests/unit/Navigation/Nodes/NodeProcedureContainerTest.php
index e2f29f6aee..7472ec3aaa 100644
--- a/tests/unit/Navigation/Nodes/NodeProcedureContainerTest.php
+++ b/tests/unit/Navigation/Nodes/NodeProcedureContainerTest.php
@@ -18,13 +18,10 @@ class NodeProcedureContainerTest extends AbstractTestCase
public function testConstructor(): void
{
$parent = new NodeProcedureContainer(new Config());
- self::assertSame(
- [
- 'text' => ['route' => '/database/routines', 'params' => ['type' => 'PROCEDURE', 'db' => null]],
- 'icon' => ['route' => '/database/routines', 'params' => ['type' => 'PROCEDURE', 'db' => null]],
- ],
- $parent->links,
- );
+ self::assertSame('/database/routines', $parent->link->route);
+ self::assertSame(['type' => 'PROCEDURE', 'db' => null], $parent->link->params);
self::assertSame('procedures', $parent->realName);
+ self::assertSame('/database/routines', $parent->icon->route);
+ self::assertSame(['type' => 'PROCEDURE', 'db' => null], $parent->icon->params);
}
}
diff --git a/tests/unit/Navigation/Nodes/NodeProcedureTest.php b/tests/unit/Navigation/Nodes/NodeProcedureTest.php
index 9369fbb6e8..88f37afb0c 100644
--- a/tests/unit/Navigation/Nodes/NodeProcedureTest.php
+++ b/tests/unit/Navigation/Nodes/NodeProcedureTest.php
@@ -18,18 +18,15 @@ class NodeProcedureTest extends AbstractTestCase
public function testConstructor(): void
{
$parent = new NodeProcedure(new Config(), 'default');
+ self::assertSame('/database/routines', $parent->link->route);
self::assertSame(
- [
- 'text' => [
- 'route' => '/database/routines',
- 'params' => ['item_type' => 'PROCEDURE', 'edit_item' => 1, 'db' => null, 'item_name' => null],
- ],
- 'icon' => [
- 'route' => '/database/routines',
- 'params' => ['item_type' => 'PROCEDURE', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
- ],
- ],
- $parent->links,
+ ['item_type' => 'PROCEDURE', 'edit_item' => 1, 'db' => null, 'item_name' => null],
+ $parent->link->params,
+ );
+ self::assertSame('/database/routines', $parent->icon->route);
+ self::assertSame(
+ ['item_type' => 'PROCEDURE', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
+ $parent->icon->params,
);
}
}
diff --git a/tests/unit/Navigation/Nodes/NodeTableContainerTest.php b/tests/unit/Navigation/Nodes/NodeTableContainerTest.php
index 22215c7cad..45a5008479 100644
--- a/tests/unit/Navigation/Nodes/NodeTableContainerTest.php
+++ b/tests/unit/Navigation/Nodes/NodeTableContainerTest.php
@@ -18,13 +18,10 @@ class NodeTableContainerTest extends AbstractTestCase
public function testConstructor(): void
{
$parent = new NodeTableContainer(new Config());
- self::assertSame(
- [
- 'text' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'table', 'db' => null]],
- 'icon' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'table', 'db' => null]],
- ],
- $parent->links,
- );
+ self::assertSame('/database/structure', $parent->link->route);
+ self::assertSame(['tbl_type' => 'table', 'db' => null], $parent->link->params);
+ self::assertSame('/database/structure', $parent->icon->route);
+ self::assertSame(['tbl_type' => 'table', 'db' => null], $parent->icon->params);
self::assertSame('tables', $parent->realName);
self::assertStringContainsString('tableContainer', $parent->classes);
}
diff --git a/tests/unit/Navigation/Nodes/NodeTableTest.php b/tests/unit/Navigation/Nodes/NodeTableTest.php
index 54984bacc1..357bbc5763 100644
--- a/tests/unit/Navigation/Nodes/NodeTableTest.php
+++ b/tests/unit/Navigation/Nodes/NodeTableTest.php
@@ -23,15 +23,14 @@ class NodeTableTest extends AbstractTestCase
$config->settings['NavigationTreeDefaultTabTable2'] = '/table/change';
$parent = new NodeTable($config, 'default');
- self::assertSame(
- [
- 'text' => ['route' => '/sql', 'params' => ['pos' => 0, 'db' => null, 'table' => null]],
- 'icon' => ['route' => '/table/search', 'params' => ['db' => null, 'table' => null]],
- 'second_icon' => ['route' => '/table/change', 'params' => ['db' => null, 'table' => null]],
- 'title' => 'Browse',
- ],
- $parent->links,
- );
+ self::assertSame('/sql', $parent->link->route);
+ self::assertSame(['pos' => 0, 'db' => null, 'table' => null], $parent->link->params);
+ self::assertSame('Browse', $parent->link->title);
+ self::assertSame('/table/search', $parent->icon->route);
+ self::assertSame(['db' => null, 'table' => null], $parent->icon->params);
+ self::assertNotNull($parent->secondIcon);
+ self::assertSame('/table/change', $parent->secondIcon->route);
+ self::assertSame(['db' => null, 'table' => null], $parent->secondIcon->params);
self::assertStringContainsString('table', $parent->classes);
}
@@ -46,8 +45,8 @@ class NodeTableTest extends AbstractTestCase
$config = Config::getInstance();
$config->settings['NavigationTreeDefaultTabTable'] = $target;
$node = new NodeTable($config, 'default');
- self::assertSame($imageName, $node->icon['image']);
- self::assertSame($imageTitle, $node->icon['title']);
+ self::assertSame($imageName, $node->icon->image);
+ self::assertSame($imageTitle, $node->icon->title);
}
/**
diff --git a/tests/unit/Navigation/Nodes/NodeTest.php b/tests/unit/Navigation/Nodes/NodeTest.php
index 0fbddcff0c..019900cfbe 100644
--- a/tests/unit/Navigation/Nodes/NodeTest.php
+++ b/tests/unit/Navigation/Nodes/NodeTest.php
@@ -531,7 +531,6 @@ final class NodeTest extends AbstractTestCase
self::assertSame('New', $node->name);
self::assertSame(NodeType::Object, $node->type);
self::assertFalse($node->isGroup);
- self::assertSame('New', $node->title);
self::assertTrue($node->isNew);
self::assertSame('new_database italics', $node->classes);
}
diff --git a/tests/unit/Navigation/Nodes/NodeTriggerContainerTest.php b/tests/unit/Navigation/Nodes/NodeTriggerContainerTest.php
index 4c57e78f19..202552ea48 100644
--- a/tests/unit/Navigation/Nodes/NodeTriggerContainerTest.php
+++ b/tests/unit/Navigation/Nodes/NodeTriggerContainerTest.php
@@ -18,13 +18,10 @@ class NodeTriggerContainerTest extends AbstractTestCase
public function testConstructor(): void
{
$parent = new NodeTriggerContainer(new Config());
- self::assertSame(
- [
- 'text' => ['route' => '/triggers', 'params' => ['db' => null, 'table' => null]],
- 'icon' => ['route' => '/triggers', 'params' => ['db' => null, 'table' => null]],
- ],
- $parent->links,
- );
+ self::assertSame('/triggers', $parent->link->route);
+ self::assertSame(['db' => null, 'table' => null], $parent->link->params);
+ self::assertSame('/triggers', $parent->icon->route);
+ self::assertSame(['db' => null, 'table' => null], $parent->icon->params);
self::assertSame('triggers', $parent->realName);
}
}
diff --git a/tests/unit/Navigation/Nodes/NodeTriggerTest.php b/tests/unit/Navigation/Nodes/NodeTriggerTest.php
index 07acc7c2de..1402edf213 100644
--- a/tests/unit/Navigation/Nodes/NodeTriggerTest.php
+++ b/tests/unit/Navigation/Nodes/NodeTriggerTest.php
@@ -18,18 +18,15 @@ class NodeTriggerTest extends AbstractTestCase
public function testConstructor(): void
{
$parent = new NodeTrigger(new Config(), 'default');
+ self::assertSame('/triggers', $parent->link->route);
self::assertSame(
- [
- 'text' => [
- 'route' => '/triggers',
- 'params' => ['edit_item' => 1, 'db' => null, 'item_name' => null],
- ],
- 'icon' => [
- 'route' => '/triggers',
- 'params' => ['export_item' => 1, 'db' => null, 'item_name' => null],
- ],
- ],
- $parent->links,
+ ['edit_item' => 1, 'db' => null, 'item_name' => null],
+ $parent->link->params,
+ );
+ self::assertSame('/triggers', $parent->icon->route);
+ self::assertSame(
+ ['export_item' => 1, 'db' => null, 'item_name' => null],
+ $parent->icon->params,
);
}
}
diff --git a/tests/unit/Navigation/Nodes/NodeViewContainerTest.php b/tests/unit/Navigation/Nodes/NodeViewContainerTest.php
index 207f3df81e..739e54c448 100644
--- a/tests/unit/Navigation/Nodes/NodeViewContainerTest.php
+++ b/tests/unit/Navigation/Nodes/NodeViewContainerTest.php
@@ -18,13 +18,10 @@ class NodeViewContainerTest extends AbstractTestCase
public function testConstructor(): void
{
$parent = new NodeViewContainer(new Config());
- self::assertSame(
- [
- 'text' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'view', 'db' => null]],
- 'icon' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'view', 'db' => null]],
- ],
- $parent->links,
- );
+ self::assertSame('/database/structure', $parent->link->route);
+ self::assertSame(['tbl_type' => 'view', 'db' => null], $parent->link->params);
+ self::assertSame('/database/structure', $parent->icon->route);
+ self::assertSame(['tbl_type' => 'view', 'db' => null], $parent->icon->params);
self::assertSame('views', $parent->realName);
self::assertStringContainsString('viewContainer', $parent->classes);
}
diff --git a/tests/unit/Navigation/Nodes/NodeViewTest.php b/tests/unit/Navigation/Nodes/NodeViewTest.php
index 05aecb91bc..888e3c8405 100644
--- a/tests/unit/Navigation/Nodes/NodeViewTest.php
+++ b/tests/unit/Navigation/Nodes/NodeViewTest.php
@@ -18,15 +18,12 @@ class NodeViewTest extends AbstractTestCase
public function testConstructor(): void
{
$parent = new NodeView(new Config(), 'default');
- self::assertSame(
- [
- 'text' => ['route' => '/sql', 'params' => ['pos' => 0, 'db' => null, 'table' => null]],
- 'icon' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
- ],
- $parent->links,
- );
- self::assertSame('b_props', $parent->icon['image']);
- self::assertSame('View', $parent->icon['title']);
+ self::assertSame('/sql', $parent->link->route);
+ self::assertSame(['pos' => 0, 'db' => null, 'table' => null], $parent->link->params);
+ self::assertSame('b_props', $parent->icon->image);
+ self::assertSame('View', $parent->icon->title);
+ self::assertSame('/table/structure', $parent->icon->route);
+ self::assertSame(['db' => null, 'table' => null], $parent->icon->params);
self::assertStringContainsString('view', $parent->classes);
}
}