@@ -22,7 +22,6 @@ private static function getVendorDir(){
2222 return $ vendorDir ;
2323 }
2424
25-
2625
2726 /**
2827 * this method retrieves settings of a package
@@ -39,29 +38,7 @@ public static function getSettings($package,$setting = null){
3938 $ settings = SettingsCache::getInstance ()->getData ($ package_ );
4039 if ($ settings === NULL ){
4140
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 );
6542
6643 $ settings = json_decode (file_get_contents ($ packageConfigFile ),true );
6744
@@ -80,5 +57,32 @@ public static function getSettings($package,$setting = null){
8057
8158 }
8259
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+
8387}
8488
0 commit comments