EditPage: Add getContext() function
authorKunal Mehta <legoktm@member.fsf.org>
Wed, 24 Aug 2016 00:48:43 +0000 (17:48 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Wed, 24 Aug 2016 01:56:59 +0000 (18:56 -0700)
EditPage already has access to a IContextSource object via
$this->mArticle->getContext(), but no code ever uses it. Add a
$this->getContext() helper function and $this->context member variable
so developers are aware that RequestContext is available and should be
used instead of globals. This is the first step to de-globalifying
EditPage.

Change-Id: I17130bdaf214e9bbe0577a0ee5564ca4760c99e1

includes/EditPage.php

index c7b014a..b5becee 100644 (file)
@@ -401,6 +401,11 @@ class EditPage {
         */
        private $enableApiEditOverride = false;
 
+       /**
+        * @var IContextSource
+        */
+       protected $context;
+
        /**
         * @param Article $article
         */
@@ -408,6 +413,7 @@ class EditPage {
                $this->mArticle = $article;
                $this->page = $article->getPage(); // model object
                $this->mTitle = $article->getTitle();
+               $this->context = $article->getContext();
 
                $this->contentModel = $this->mTitle->getContentModel();
 
@@ -422,6 +428,14 @@ class EditPage {
                return $this->mArticle;
        }
 
+       /**
+        * @since 1.28
+        * @return IContextSource
+        */
+       public function getContext() {
+               return $this->context;
+       }
+
        /**
         * @since 1.19
         * @return Title