Merge "Replace Linker::link() usage with LinkRenderer"
[lhc/web/wiklou.git] / includes / TemplateParser.php
index 8ce3420..470a75c 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+use MediaWiki\MediaWikiServices;
+
 /**
  * Handles compiling Mustache templates into PHP rendering functions
  *
@@ -38,7 +40,7 @@ class TemplateParser {
 
        /**
         * @param string $templateDir
-        * @param boolean $forceRecompile
+        * @param bool $forceRecompile
         */
        public function __construct( $templateDir = null, $forceRecompile = false ) {
                $this->templateDir = $templateDir ?: __DIR__ . '/templates';
@@ -98,7 +100,7 @@ class TemplateParser {
                $fastHash = md5( $fileContents );
 
                // Fetch a secret key for building a keyed hash of the PHP code
-               $config = ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
+               $config = MediaWikiServices::getInstance()->getMainConfig();
                $secretKey = $config->get( 'SecretKey' );
 
                if ( $secretKey ) {
@@ -170,13 +172,13 @@ class TemplateParser {
                }
                return LightnCandy::compile(
                        $code,
-                       array(
+                       [
                                // Do not add more flags here without discussion.
                                // If you do add more flags, be sure to update unit tests as well.
                                'flags' => LightnCandy::FLAG_ERROR_EXCEPTION,
                                'basedir' => $this->templateDir,
                                'fileext' => '.mustache',
-                       )
+                       ]
                );
        }
 
@@ -186,10 +188,10 @@ class TemplateParser {
         * @code
         *     echo $templateParser->processTemplate(
         *         'ExampleTemplate',
-        *         array(
+        *         [
         *             'username' => $user->getName(),
         *             'message' => 'Hello!'
-        *         )
+        *         ]
         *     );
         * @endcode
         * @param string $templateName The name of the template
@@ -197,7 +199,7 @@ class TemplateParser {
         * @param array $scopes
         * @return string
         */
-       public function processTemplate( $templateName, $args, array $scopes = array() ) {
+       public function processTemplate( $templateName, $args, array $scopes = [] ) {
                $template = $this->getTemplate( $templateName );
                return call_user_func( $template, $args, $scopes );
        }