Merge "Begin exposing SiteConfiguration via site contexts"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 9 Dec 2013 12:28:51 +0000 (12:28 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 9 Dec 2013 12:28:51 +0000 (12:28 +0000)
includes/context/ContextSource.php
includes/context/DerivativeContext.php
includes/context/IContextSource.php
includes/context/RequestContext.php

index 0a3f18f..186b8e6 100644 (file)
@@ -59,6 +59,16 @@ abstract class ContextSource implements IContextSource {
                $this->context = $context;
        }
 
+       /**
+        * Get the SiteConfiguration object
+        *
+        * @since 1.23
+        * @return SiteConfiguration
+        */
+       public function getConfig() {
+               return $this->getContext()->getConfig();
+       }
+
        /**
         * Get the WebRequest object
         *
index e96269d..1e3fbf2 100644 (file)
@@ -65,6 +65,11 @@ class DerivativeContext extends ContextSource {
         */
        private $skin;
 
+       /**
+        * @var SiteConfiguration
+        */
+       private $config;
+
        /**
         * Constructor
         * @param IContextSource $context Context to inherit from
@@ -73,6 +78,28 @@ class DerivativeContext extends ContextSource {
                $this->setContext( $context );
        }
 
+       /**
+        * Set the SiteConfiguration object
+        *
+        * @param SiteConfiguration $c
+        */
+       public function setConfig( SiteConfiguration $s ) {
+               $this->config = $s;
+       }
+
+       /**
+        * Get the SiteConfiguration object
+        *
+        * @return SiteConfiguration
+        */
+       public function getConfig() {
+               if ( !is_null( $this->config ) ) {
+                       return $this->config;
+               } else {
+                       return $this->getContext()->getConfig();
+               }
+       }
+
        /**
         * Set the WebRequest object
         *
index 35d5aed..6c5c0a2 100644 (file)
@@ -99,6 +99,14 @@ interface IContextSource {
         */
        public function getSkin();
 
+       /**
+        * Get the site configuration
+        *
+        * @since 1.23
+        * @return SiteConfiguration
+        */
+       public function getConfig();
+
        /**
         * Get a Message object with context set
         *
index 04879e2..5f91731 100644 (file)
@@ -63,6 +63,33 @@ class RequestContext implements IContextSource {
         */
        private $skin;
 
+       /**
+        * @var SiteConfiguration
+        */
+       private $config;
+
+       /**
+        * Set the SiteConfiguration object
+        *
+        * @param SiteConfiguration $c
+        */
+       public function setConfig( SiteConfiguration $c ) {
+               $this->config = $c;
+       }
+
+       /**
+        * Get the SiteConfiguration object
+        *
+        * @return SiteConfiguration
+        */
+       public function getConfig() {
+               if ( $this->config === null ) {
+                       global $wgConf;
+                       $this->config = $wgConf;
+               }
+               return $this->config;
+       }
+
        /**
         * Set the WebRequest object
         *