From 7222312fd9dc87629220bb51b364a617072c340c Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Wed, 1 Apr 2015 00:01:41 -0700 Subject: [PATCH] installer: Reduce some code duplication in LocalSettingsGenerator Change-Id: Ie3c2e56ac4d20d6d547e89a4d6c6331f4222409b --- includes/installer/LocalSettingsGenerator.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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 * -- 2.20.1