Allow adding arbitrary properties to OutputPage
authorMax Semenik <maxsem.wiki@gmail.com>
Fri, 8 Feb 2013 22:58:38 +0000 (02:58 +0400)
committerMax Semenik <maxsem.wiki@gmail.com>
Fri, 8 Feb 2013 22:58:38 +0000 (02:58 +0400)
Helps to pass extension-specific data

Change-Id: Iea98510abc100128733361f2d2287802f35bb359

includes/OutputPage.php

index 89d7c0b..b0ee815 100644 (file)
@@ -248,6 +248,11 @@ class OutputPage extends ContextSource {
         */
        private $mRedirectedFrom = null;
 
+       /**
+        * Additional key => value data
+        */
+       private $mProperties = array();
+
        /**
         * Constructor for OutputPage. This should not be called directly.
         * Instead a new RequestContext should be created and it will implicitly create
@@ -620,6 +625,32 @@ class OutputPage extends ContextSource {
                return $this->mArticleBodyOnly;
        }
 
+       /**
+        * Set an additional output property
+        * @since 1.21
+        *
+        * @param string $name
+        * @param mixed $value
+        */
+       public function setProperty( $name, $value ) {
+               $this->mProperties[$name] = $value;
+       }
+
+       /**
+        * Get an additional output property
+        * @since 1.21
+        *
+        * @param $name
+        * @return mixed: Property value or null if not found
+        */
+       public function getProperty( $name ) {
+               if ( isset( $this->mProperties[$name] ) ) {
+                       return $this->mProperties[$name];
+               } else {
+                       return null;
+               }
+       }
+
        /**
         * checkLastModified tells the client to use the client-cached page if
         * possible. If successful, the OutputPage is disabled so that