@@ -55,22 +55,26 @@ class Header
5555 */
5656 private bool $ warningsEnabled = true ;
5757
58- private UserPreferences $ userPreferences ;
59-
6058 private bool $ isTransformationWrapper = false ;
6159
6260 public function __construct (
6361 private readonly Template $ template ,
6462 private readonly Console $ console ,
6563 private readonly Config $ config ,
64+ private readonly DatabaseInterface $ dbi ,
65+ private readonly Relation $ relation ,
66+ private readonly UserPreferences $ userPreferences ,
6667 ) {
67- $ dbi = DatabaseInterface ::getInstance ();
68- $ relation = new Relation ($ dbi );
69- $ this ->menu = new Menu ($ dbi , $ this ->template , $ this ->config , $ relation , Current::$ database , Current::$ table );
68+ $ this ->menu = new Menu (
69+ $ this ->dbi ,
70+ $ this ->template ,
71+ $ this ->config ,
72+ $ this ->relation ,
73+ Current::$ database ,
74+ Current::$ table ,
75+ );
7076 $ this ->scripts = new Scripts ($ this ->template );
7177 $ this ->addDefaultScripts ();
72-
73- $ this ->userPreferences = new UserPreferences ($ dbi , $ relation , $ this ->template );
7478 }
7579
7680 private function isMenuEnabled (): bool
@@ -79,8 +83,7 @@ private function isMenuEnabled(): bool
7983 return $ this ->isMenuEnabled ;
8084 }
8185
82- $ dbi = DatabaseInterface ::getInstance ();
83- $ this ->isMenuEnabled = $ dbi ->isConnected ();
86+ $ this ->isMenuEnabled = $ this ->dbi ->isConnected ();
8487
8588 return $ this ->isMenuEnabled ;
8689 }
@@ -132,7 +135,7 @@ public function getJsParams(): array
132135 'confirm ' => $ this ->config ->settings ['Confirm ' ],
133136 'LoginCookieValidity ' => $ this ->config ->settings ['LoginCookieValidity ' ],
134137 'session_gc_maxlifetime ' => (int ) ini_get ('session.gc_maxlifetime ' ),
135- 'logged_in ' => DatabaseInterface :: getInstance () ->isConnected (),
138+ 'logged_in ' => $ this -> dbi ->isConnected (),
136139 'is_https ' => $ this ->config ->isHttps (),
137140 'rootPath ' => $ this ->config ->getRootPath (),
138141 'arg_separator ' => Url ::getArgSeparator (),
@@ -256,9 +259,8 @@ public function getDisplay(): array
256259 );
257260 $ this ->scripts ->addFiles ($ this ->console ->getScripts ());
258261
259- $ dbi = DatabaseInterface ::getInstance ();
260262 if ($ this ->isMenuEnabled () && Current::$ server > 0 ) {
261- $ navigation = (new Navigation ($ this ->template , new Relation ( $ dbi ) , $ dbi , $ this ->config ))->getDisplay ();
263+ $ navigation = (new Navigation ($ this ->template , $ this -> relation , $ this -> dbi , $ this ->config ))->getDisplay ();
262264 }
263265
264266 $ customHeader = self ::renderHeader ();
@@ -277,7 +279,7 @@ public function getDisplay(): array
277279
278280 $ console = $ this ->console ->getDisplay ();
279281 $ messages = $ this ->getMessage ();
280- $ isLoggedIn = $ dbi ->isConnected ();
282+ $ isLoggedIn = $ this -> dbi ->isConnected ();
281283
282284 $ this ->scripts ->addFile ('datetimepicker.js ' );
283285 $ this ->scripts ->addFile ('validator-messages.js ' );
@@ -303,8 +305,8 @@ public function getDisplay(): array
303305 'theme_color_mode ' => $ theme ->getColorMode (),
304306 'theme_color_modes ' => $ theme ->getColorModes (),
305307 'theme_id ' => $ theme ->getId (),
306- 'current_user ' => $ dbi ->getCurrentUserAndHost (),
307- 'is_mariadb ' => $ dbi ->isMariaDB (),
308+ 'current_user ' => $ this -> dbi ->getCurrentUserAndHost (),
309+ 'is_mariadb ' => $ this -> dbi ->isMariaDB (),
308310 ];
309311 }
310312
0 commit comments