@@ -201,7 +201,7 @@ public function __construct(private Template $template, private DatabaseInterfac
201201 }
202202
203203 // Initialize the tree by creating a root node
204- $ this ->tree = NodeFactory:: getInstance (NodeDatabaseContainer::class, 'root ' );
204+ $ this ->tree = new NodeDatabaseContainer ( 'root ' );
205205 if (! $ GLOBALS ['cfg ' ]['NavigationTreeEnableGrouping ' ] || ! $ GLOBALS ['cfg ' ]['ShowDatabasesNavigationAsTree ' ]) {
206206 return ;
207207 }
@@ -315,7 +315,7 @@ private function buildPath(): Node|bool
315315 $ data = $ this ->tree ->getData ($ this ->relationParameters , 'databases ' , $ this ->pos , $ this ->searchClause );
316316 $ hiddenCounts = $ this ->tree ->getNavigationHidingData ($ this ->relationParameters ->navigationItemsHidingFeature );
317317 foreach ($ data as $ db ) {
318- $ node = NodeFactory:: getInstance (NodeDatabase::class, $ db );
318+ $ node = new NodeDatabase ( $ db );
319319 if (isset ($ hiddenCounts [$ db ])) {
320320 $ node ->setHiddenCount ((int ) $ hiddenCounts [$ db ]);
321321 }
@@ -388,27 +388,16 @@ private function buildPathPart(array $path, string $type2, int $pos2, string $ty
388388 if (count ($ container ->children ) <= 1 ) {
389389 $ dbData = $ db ->getData ($ this ->relationParameters , $ container ->realName , $ pos2 , $ this ->searchClause2 );
390390 foreach ($ dbData as $ item ) {
391- switch ($ container ->realName ) {
392- case 'events ' :
393- $ node = NodeFactory::getInstance (NodeEvent::class, $ item );
394- break ;
395- case 'functions ' :
396- $ node = NodeFactory::getInstance (NodeFunction::class, $ item );
397- break ;
398- case 'procedures ' :
399- $ node = NodeFactory::getInstance (NodeProcedure::class, $ item );
400- break ;
401- case 'tables ' :
402- $ node = NodeFactory::getInstance (NodeTable::class, $ item );
403- break ;
404- case 'views ' :
405- $ node = NodeFactory::getInstance (NodeView::class, $ item );
406- break ;
407- default :
408- break ;
409- }
410-
411- if (! isset ($ node )) {
391+ $ node = match ($ container ->realName ) {
392+ 'events ' => new NodeEvent ($ item ),
393+ 'functions ' => new NodeFunction ($ item ),
394+ 'procedures ' => new NodeProcedure ($ item ),
395+ 'tables ' => new NodeTable ($ item ),
396+ 'views ' => new NodeView ($ item ),
397+ default => null ,
398+ };
399+
400+ if ($ node === null ) {
412401 continue ;
413402 }
414403
@@ -436,7 +425,7 @@ private function buildPathPart(array $path, string $type2, int $pos2, string $ty
436425 return false ;
437426 }
438427
439- $ node = NodeFactory:: getInstance (NodeTable::class, $ path [0 ]);
428+ $ node = new NodeTable ( $ path [0 ]);
440429 if ($ type2 === $ container ->realName ) {
441430 $ node ->pos2 = $ pos2 ;
442431 }
@@ -461,21 +450,14 @@ private function buildPathPart(array $path, string $type2, int $pos2, string $ty
461450
462451 $ tableData = $ table ->getData ($ this ->relationParameters , $ container ->realName , $ pos3 );
463452 foreach ($ tableData as $ item ) {
464- switch ($ container ->realName ) {
465- case 'indexes ' :
466- $ node = NodeFactory::getInstance (NodeIndex::class, $ item );
467- break ;
468- case 'columns ' :
469- $ node = NodeFactory::getInstance (NodeColumn::class, $ item );
470- break ;
471- case 'triggers ' :
472- $ node = NodeFactory::getInstance (NodeTrigger::class, $ item );
473- break ;
474- default :
475- break ;
476- }
477-
478- if (! isset ($ node )) {
453+ $ node = match ($ container ->realName ) {
454+ 'indexes ' => new NodeIndex ($ item ),
455+ 'columns ' => new NodeColumn ($ item ),
456+ 'triggers ' => new NodeTrigger ($ item ),
457+ default => null ,
458+ };
459+
460+ if ($ node === null ) {
479461 continue ;
480462 }
481463
@@ -512,15 +494,15 @@ private function addTableContainers(NodeTable $table, int $pos2, string $type3,
512494 $ retval = [];
513495 if (! $ table ->hasChildren ()) {
514496 if ($ table ->getPresence ('columns ' )) {
515- $ retval ['columns ' ] = NodeFactory:: getInstance ( NodeColumnContainer::class );
497+ $ retval ['columns ' ] = new NodeColumnContainer ( );
516498 }
517499
518500 if ($ table ->getPresence ('indexes ' )) {
519- $ retval ['indexes ' ] = NodeFactory:: getInstance ( NodeIndexContainer::class );
501+ $ retval ['indexes ' ] = new NodeIndexContainer ( );
520502 }
521503
522504 if ($ table ->getPresence ('triggers ' )) {
523- $ retval ['triggers ' ] = NodeFactory:: getInstance ( NodeTriggerContainer::class );
505+ $ retval ['triggers ' ] = new NodeTriggerContainer ( );
524506 }
525507
526508 // Add all new Nodes to the tree
@@ -587,23 +569,23 @@ private function addDbContainers(NodeDatabase $db, string $type, int $pos2): arr
587569 $ retval = [];
588570 if (! $ db ->hasChildren ()) {
589571 if (! in_array ('tables ' , $ hidden ) && $ db ->getPresence ('tables ' )) {
590- $ retval ['tables ' ] = NodeFactory:: getInstance ( NodeTableContainer::class );
572+ $ retval ['tables ' ] = new NodeTableContainer ( );
591573 }
592574
593575 if (! in_array ('views ' , $ hidden ) && $ db ->getPresence ('views ' )) {
594- $ retval ['views ' ] = NodeFactory:: getInstance ( NodeViewContainer::class );
576+ $ retval ['views ' ] = new NodeViewContainer ( );
595577 }
596578
597579 if (! in_array ('functions ' , $ hidden ) && $ db ->getPresence ('functions ' )) {
598- $ retval ['functions ' ] = NodeFactory:: getInstance ( NodeFunctionContainer::class );
580+ $ retval ['functions ' ] = new NodeFunctionContainer ( );
599581 }
600582
601583 if (! in_array ('procedures ' , $ hidden ) && $ db ->getPresence ('procedures ' )) {
602- $ retval ['procedures ' ] = NodeFactory:: getInstance ( NodeProcedureContainer::class );
584+ $ retval ['procedures ' ] = new NodeProcedureContainer ( );
603585 }
604586
605587 if (! in_array ('events ' , $ hidden ) && $ db ->getPresence ('events ' )) {
606- $ retval ['events ' ] = NodeFactory:: getInstance ( NodeEventContainer::class );
588+ $ retval ['events ' ] = new NodeEventContainer ( );
607589 }
608590
609591 // Add all new Nodes to the tree
@@ -654,7 +636,7 @@ public function groupTree(Node|null $node = null): void
654636 */
655637 public function groupNode (Node $ node ): void
656638 {
657- if ($ node ->type != Node:: CONTAINER || ! $ GLOBALS ['cfg ' ]['NavigationTreeEnableExpansion ' ]) {
639+ if ($ node ->type !== NodeType::Container || ! $ GLOBALS ['cfg ' ]['NavigationTreeEnableExpansion ' ]) {
658640 return ;
659641 }
660642
@@ -761,18 +743,12 @@ public function groupNode(Node $node): void
761743 $ nameSubstring = mb_substr ($ child ->name , 0 , $ keySeparatorLength );
762744 if (
763745 ($ nameSubstring !== $ key . $ separator && $ child ->name !== $ key )
764- || $ child ->type != Node:: OBJECT
746+ || $ child ->type !== NodeType::Object
765747 ) {
766748 continue ;
767749 }
768750
769- $ newChild = NodeFactory::getInstance (
770- $ child ::class,
771- mb_substr (
772- $ child ->name ,
773- $ keySeparatorLength ,
774- ),
775- );
751+ $ newChild = new $ child (mb_substr ($ child ->name , $ keySeparatorLength ));
776752 if ($ child instanceof NodeDatabase && $ child ->getHiddenCount () > 0 ) {
777753 $ newChild ->setHiddenCount ($ child ->getHiddenCount ());
778754 }
@@ -806,7 +782,7 @@ public function groupNode(Node $node): void
806782 $ node ->addChild ($ newChild ['node ' ]);
807783 }
808784 } else {
809- $ groups [$ key ] = new Node ((string ) $ key , Node:: CONTAINER , true );
785+ $ groups [$ key ] = new Node ((string ) $ key , NodeType::Container , true );
810786 $ groups [$ key ]->separator = $ node ->separator ;
811787 $ groups [$ key ]->separatorDepth = $ node ->separatorDepth - 1 ;
812788 $ groups [$ key ]->icon = ['image ' => 'b_group ' , 'title ' => __ ('Groups ' )];
@@ -1020,7 +996,7 @@ private function renderNode(Node $node, string $class = ''): string
1020996 {
1021997 $ controlButtons = '' ;
1022998 $ paths = $ node ->getPaths ();
1023- $ nodeIsContainer = $ node ->type === Node:: CONTAINER ;
999+ $ nodeIsContainer = $ node ->type === NodeType::Container ;
10241000 $ liClasses = '' ;
10251001
10261002 // Whether to show the node in the tree (true for all nodes but root)
@@ -1063,7 +1039,7 @@ private function renderNode(Node $node, string $class = ''): string
10631039 $ haveAjax = ['functions ' , 'procedures ' , 'events ' , 'triggers ' , 'indexes ' ];
10641040 $ parent = $ node ->parents (false , true );
10651041 $ isNewView = $ parent [0 ]->realName === 'views ' && $ node ->isNew ;
1066- $ linkHasAjaxClass = $ parent [0 ]->type == Node:: CONTAINER
1042+ $ linkHasAjaxClass = $ parent [0 ]->type === NodeType::Container
10671043 && (in_array ($ parent [0 ]->realName , $ haveAjax ) || $ isNewView );
10681044
10691045 if (! $ node ->isGroup ) {
@@ -1260,7 +1236,7 @@ private function fastFilterHtml(Node $node): string
12601236 if ($ isRootNode ) {
12611237 $ urlParams = ['pos ' => 0 ];
12621238 } else {
1263- $ nodeIsContainer = $ node ->type === Node:: CONTAINER ;
1239+ $ nodeIsContainer = $ node ->type === NodeType::Container ;
12641240
12651241 $ nodeIsSpecial = in_array ($ node ->realName , self ::SPECIAL_NODE_NAMES , true );
12661242
@@ -1336,7 +1312,7 @@ private function getPageSelector(Node $node): string
13361312 'pos ' ,
13371313 ['dbselector ' ],
13381314 );
1339- } elseif ($ node ->type == Node:: CONTAINER && ! $ node ->isGroup ) {
1315+ } elseif ($ node ->type === NodeType::Container && ! $ node ->isGroup ) {
13401316 $ paths = $ node ->getPaths ();
13411317 $ level = isset ($ paths ['aPath_clean ' ][4 ]) ? 3 : 2 ;
13421318 $ urlParams = [
0 commit comments