@@ -22,7 +22,6 @@ private static function getVendorDir(){
22
22
return $ vendorDir ;
23
23
}
24
24
25
-
26
25
27
26
/**
28
27
* this method retrieves settings of a package
@@ -39,29 +38,7 @@ public static function getSettings($package,$setting = null){
39
38
$ settings = SettingsCache::getInstance ()->getData ($ package_ );
40
39
if ($ settings === NULL ){
41
40
42
- $ vendorDir = self ::getVendorDir ();
43
-
44
- $ packageConfigFile = $ vendorDir .'/ ' .$ package .'/config.json ' ;
45
-
46
- if (!file_exists ($ packageConfigFile )){
47
- // if no config.json in vendor directory ,
48
- // try to find the current package's config.json
49
- $ thisPackageRoot = dirname ($ vendorDir );
50
- while (!file_exists ($ thisPackageRoot .'/composer.json ' )){
51
- $ thisPackageRoot_ = dirname ($ thisPackageRoot );
52
- if ($ thisPackageRoot == $ thisPackageRoot_ ){
53
- throw new \Exception ("No configuration found for the package $ package " );
54
- }
55
- $ thisPackageRoot = $ thisPackageRoot_ ;
56
- }
57
- $ composerJson = json_decode (file_get_contents ($ thisPackageRoot .'/composer.json ' ),true );
58
- if ($ composerJson ["name " ] == $ package ){
59
- $ packageConfigFile = $ thisPackageRoot .'/config.json ' ;
60
- }
61
- if (!file_exists ($ packageConfigFile )){
62
- throw new \Exception ("No configuration found for the package $ package " );
63
- }
64
- }
41
+ $ packageConfigFile = self ::getConfigFile ($ package );
65
42
66
43
$ settings = json_decode (file_get_contents ($ packageConfigFile ),true );
67
44
@@ -80,5 +57,32 @@ public static function getSettings($package,$setting = null){
80
57
81
58
}
82
59
60
+ public static function getConfigFile ($ package ){
61
+ $ vendorDir = self ::getVendorDir ();
62
+
63
+ $ packageConfigFile = $ vendorDir .'/ ' .$ package .'/config.json ' ;
64
+ if (!file_exists ($ packageConfigFile )){
65
+ // if no config.json in vendor directory ,
66
+ // try to find the current package's config.json
67
+ $ thisPackageRoot = dirname ($ vendorDir );
68
+ while (!file_exists ($ thisPackageRoot .'/composer.json ' )){
69
+ $ thisPackageRoot_ = dirname ($ thisPackageRoot );
70
+ if ($ thisPackageRoot == $ thisPackageRoot_ ){
71
+ throw new \Exception ("No configuration found for the package $ package " );
72
+ }
73
+ $ thisPackageRoot = $ thisPackageRoot_ ;
74
+ }
75
+ $ composerJson = json_decode (file_get_contents ($ thisPackageRoot .'/composer.json ' ),true );
76
+ if ($ composerJson ["name " ] == $ package ){
77
+ $ packageConfigFile = $ thisPackageRoot .'/config.json ' ;
78
+ }
79
+
80
+ if (!file_exists ($ packageConfigFile )){
81
+ throw new \Exception ("No configuration found for the package $ package " );
82
+ }
83
+ }
84
+ return $ packageConfigFile ;
85
+ }
86
+
83
87
}
84
88
0 commit comments