installer: Reduce some code duplication in LocalSettingsGenerator
authorKunal Mehta <legoktm@gmail.com>
Wed, 1 Apr 2015 07:01:41 +0000 (00:01 -0700)
committerKunal Mehta <legoktm@gmail.com>
Wed, 1 Apr 2015 07:01:41 +0000 (00:01 -0700)
Change-Id: Ie3c2e56ac4d20d6d547e89a4d6c6331f4222409b

includes/installer/LocalSettingsGenerator.php

index 8724e0d..3ba5e37 100644 (file)
@@ -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
         *