@@ -26,7 +26,7 @@ class Config extends Foundation
2626 *
2727 * @var array<string, string>
2828 */
29- private $ valueToMethod = [
29+ private array $ valueToMethods = [
3030 'bootstrap ' => 'getBootstrap ' ,
3131 'git-directory ' => 'getGitDirectory ' ,
3232 'php-path ' => 'getPhpPath ' ,
@@ -53,16 +53,50 @@ public function replacement(array $options): string
5353 */
5454 private function getConfigValueFor (string $ value ): string
5555 {
56+ // check if the value should be a custom config value
5657 if (str_starts_with ($ value , 'custom>> ' )) {
57- $ key = substr ($ value , 8 );
58- $ custom = $ this ->config ->getCustomSettings ();
59- return $ custom [$ key ] ?? '' ;
58+ return $ this ->findCustomConfigValue ($ value );
6059 }
61- if (!isset ($ this ->valueToMethod [$ value ])) {
60+ // check if the value should be a plugin config value
61+ if (str_starts_with ($ value , 'plugin>> ' )) {
62+ return $ this ->findPluginConfigValue ($ value );
63+ }
64+ // if we don't know what method to call, return an empty string
65+ if (!isset ($ this ->valueToMethods [$ value ])) {
6266 return '' ;
6367 }
6468
65- $ method = $ this ->valueToMethod [$ value ];
69+ $ method = $ this ->valueToMethods [$ value ];
6670 return $ this ->config ->$ method ();
6771 }
72+
73+ /**
74+ * Returns a custom configuration value
75+ *
76+ * @param string $value
77+ * @return string
78+ */
79+ private function findCustomConfigValue (string $ value ): string
80+ {
81+ $ key = substr ($ value , 8 );
82+ $ custom = $ this ->config ->getCustomSettings ();
83+ return $ custom [$ key ] ?? '' ;
84+ }
85+
86+ /**
87+ * Returns a option value for a plugin configuration
88+ *
89+ * @param string $value
90+ * @return string
91+ */
92+ private function findPluginConfigValue (string $ value ): string
93+ {
94+ [$ pluginClass , $ key ] = explode ('. ' , substr ($ value , 8 ));
95+ foreach ($ this ->config ->getPlugins () as $ plugin ) {
96+ if ($ plugin ->getPlugin () === $ pluginClass ) {
97+ return $ plugin ->getOptions ()->get ($ key );
98+ }
99+ }
100+ return '' ;
101+ }
68102}
0 commit comments