@@ -30,6 +30,7 @@ class Reader
3030 ];
3131
3232 private $ app_env ;
33+ private ?string $ app_root ;
3334 private ?array $ config = [];
3435 private ?array $ databases = [];
3536 private string $ drupal_version ;
@@ -40,10 +41,15 @@ class Reader
4041 private $ omen ;
4142 private ?array $ settings = [];
4243
43- public function __construct (string $ settings_dir )
44+ public function __construct (array $ vars )
4445 {
45- global $ config , $ databases , $ settings ;
46+ unset($ vars ['class_loader ' ]);
47+ extract ($ vars );
48+ unset($ vars );
4649
50+ $ settings_dir = $ app_root . self ::DS . $ site_path ;
51+
52+ $ this ->app_root = $ app_root ;
4753 $ this ->config = &$ config ;
4854 $ this ->databases = &$ databases ;
4955 $ this ->settings = &$ settings ;
@@ -114,12 +120,17 @@ public function __construct(string $settings_dir)
114120 $ this ->setDatabaseConnection ();
115121 }
116122
123+ public static function get (array $ vars ) : array
124+ {
125+ return (new Reader ($ vars ))->getConf ();
126+ }
127+
117128 /**
118129 * Get read configuration.
119130 *
120131 * @return array
121132 */
122- public function get () : array
133+ public function getConf () : array
123134 {
124135 $ conf = [
125136 'config ' => $ this ->config ,
@@ -143,9 +154,10 @@ public function get() : array
143154 /**
144155 * Print out configuration.
145156 */
146- public function show ()
157+ public static function show (array $ vars )
147158 {
148- $ this ->printConfiguration ($ this ->get ());
159+ $ reader = new Reader ($ vars );
160+ $ reader ->printConfiguration ($ reader ->getConf ());
149161 }
150162
151163 protected function printConfiguration ($ conf )
0 commit comments