Add base interface for setters in RequestContext and DerivativeContext
authorKunal Mehta <legoktm@gmail.com>
Mon, 21 Jul 2014 09:13:23 +0000 (02:13 -0700)
committerAddshore <addshorewiki@gmail.com>
Mon, 3 Aug 2015 11:55:41 +0000 (11:55 +0000)
Change-Id: I819633ca5344f73a196623569bb58fd8372d6779

autoload.php
includes/context/DerivativeContext.php
includes/context/MutableContext.php [new file with mode: 0644]
includes/context/RequestContext.php

index 911c7c8..0d2e4a8 100644 (file)
@@ -799,6 +799,7 @@ $wgAutoloadLocalClasses = array(
        'MultiHttpClient' => __DIR__ . '/includes/libs/MultiHttpClient.php',
        'MultiWriteBagOStuff' => __DIR__ . '/includes/objectcache/MultiWriteBagOStuff.php',
        'MutableConfig' => __DIR__ . '/includes/config/MutableConfig.php',
+       'MutableContext' => __DIR__ . '/includes/context/MutableContext.php',
        'MwSql' => __DIR__ . '/maintenance/sql.php',
        'MyLocalSettingsGenerator' => __DIR__ . '/mw-config/overrides.php',
        'MySQLField' => __DIR__ . '/includes/db/DatabaseMysqlBase.php',
index aaa1fa7..09c3939 100644 (file)
@@ -26,7 +26,7 @@
  *     a different Title instance set on it.
  * @since 1.19
  */
-class DerivativeContext extends ContextSource {
+class DerivativeContext extends ContextSource implements MutableContext {
        /**
         * @var WebRequest
         */
diff --git a/includes/context/MutableContext.php b/includes/context/MutableContext.php
new file mode 100644 (file)
index 0000000..6358f11
--- /dev/null
@@ -0,0 +1,82 @@
+<?php
+/**
+ * Request-dependant objects containers.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 1.26
+ *
+ * @file
+ */
+
+interface MutableContext {
+       /**
+        * Set the Config object
+        *
+        * @param Config $c
+        */
+       public function setConfig( Config $c );
+
+       /**
+        * Set the WebRequest object
+        *
+        * @param WebRequest $r
+        */
+       public function setRequest( WebRequest $r );
+
+       /**
+        * Set the Title object
+        *
+        * @param Title $t
+        */
+       public function setTitle( Title $t );
+
+       /**
+        * Set the WikiPage object
+        *
+        * @param WikiPage $p
+        */
+       public function setWikiPage( WikiPage $p );
+
+       /**
+        * Set the OutputPage object
+        *
+        * @param OutputPage $o
+        */
+       public function setOutput( OutputPage $o );
+
+       /**
+        * Set the User object
+        *
+        * @param User $u
+        */
+       public function setUser( User $u );
+
+       /**
+        * Set the Language object
+        *
+        * @param Language|string $l Language instance or language code
+        */
+       public function setLanguage( $l );
+
+       /**
+        * Set the Skin object
+        *
+        * @param Skin $s
+        */
+       public function setSkin( Skin $s );
+
+}
index 99c1a06..76b5e52 100644 (file)
@@ -25,7 +25,7 @@
 /**
  * Group all the pieces relevant to the context of a request into one instance
  */
-class RequestContext implements IContextSource {
+class RequestContext implements IContextSource, MutableContext {
        /**
         * @var WebRequest
         */