From: Kunal Mehta Date: Wed, 1 Apr 2015 07:01:41 +0000 (-0700) Subject: installer: Reduce some code duplication in LocalSettingsGenerator X-Git-Tag: 1.31.0-rc.0~11908 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=7222312fd9dc87629220bb51b364a617072c340c;p=lhc%2Fweb%2Fwiklou.git installer: Reduce some code duplication in LocalSettingsGenerator Change-Id: Ie3c2e56ac4d20d6d547e89a4d6c6331f4222409b --- diff --git a/includes/installer/LocalSettingsGenerator.php b/includes/installer/LocalSettingsGenerator.php index 8724e0df33..3ba5e37aab 100644 --- a/includes/installer/LocalSettingsGenerator.php +++ b/includes/installer/LocalSettingsGenerator.php @@ -143,8 +143,7 @@ class LocalSettingsGenerator { # The following skins were automatically enabled:\n"; foreach ( $this->skins as $skinName ) { - $encSkinName = self::escapePhpString( $skinName ); - $localSettings .= "require_once \"\$IP/skins/$encSkinName/$encSkinName.php\";\n"; + $localSettings .= $this->generateRequireOnceLine( 'skins', $skinName ); } $localSettings .= "\n"; @@ -157,8 +156,7 @@ class LocalSettingsGenerator { # The following extensions were automatically enabled:\n"; foreach ( $this->extensions as $extName ) { - $encExtName = self::escapePhpString( $extName ); - $localSettings .= "require_once \"\$IP/extensions/$encExtName/$encExtName.php\";\n"; + $localSettings .= $this->generateRequireOnceLine( 'extensions', $extName ); } $localSettings .= "\n"; @@ -171,6 +169,16 @@ class LocalSettingsGenerator { return $localSettings; } + /** + * @param string $dir Either "extensions" or "skins" + * @param string $name Name of extension/skin + * @return string + */ + private function generateRequireOnceLine( $dir, $name ) { + $encName = self::escapePhpString( $name ); + return "require_once \"\$IP/$dir/$encName/$encName.php\";\n"; + } + /** * Write the generated LocalSettings to a file *