Let subclasses specify their associated content class for JSONContentHandler
authorKunal Mehta <legoktm@gmail.com>
Fri, 8 Aug 2014 23:51:19 +0000 (00:51 +0100)
committerReedy <reedy@wikimedia.org>
Sat, 9 Aug 2014 00:06:31 +0000 (00:06 +0000)
Also add @since tags and release notes

Change-Id: I515a51f40b7820a3d45b1219d21923467abe5ecd

RELEASE-NOTES-1.24
includes/content/JSONContent.php
includes/content/JSONContentHandler.php

index ae2ab4f..d68d529 100644 (file)
@@ -146,6 +146,7 @@ production.
 * (bug 15484) Users will now be redirected to the login page when they need to
   log in, rather than being shown a page asking them to log in and having to click
   another link to actually get to the login page.
+* A JSONContent and JSONContentHandler were added for extensions to extend.
 
 === Bug fixes in 1.24 ===
 * (bug 49116) Footer copyright notice is now always displayed in user language
index 0fa9282..16bb279 100644 (file)
@@ -10,6 +10,7 @@
 
 /**
  * Represents the content of a JSON content.
+ * @since 1.24
  */
 class JSONContent extends TextContent {
 
index b290fb2..9d001da 100644 (file)
@@ -8,8 +8,18 @@
  * @author Kunal Mehta <legoktm@gmail.com>
  */
 
+/**
+ * @since 1.24
+ */
 class JSONContentHandler extends TextContentHandler {
 
+       /**
+        * The class name of objects that should be created
+        *
+        * @var string
+        */
+       protected $contentClass = 'JSONContent';
+
        public function __construct( $modelId = CONTENT_MODEL_JSON ) {
                parent::__construct( $modelId, array( CONTENT_FORMAT_JSON ) );
        }
@@ -24,7 +34,7 @@ class JSONContentHandler extends TextContentHandler {
         */
        public function unserializeContent( $text, $format = null ) {
                $this->checkFormat( $format );
-               return new JSONContent( $text );
+               return new $this->contentClass( $text );
        }
 
        /**
@@ -33,7 +43,7 @@ class JSONContentHandler extends TextContentHandler {
         * @return JSONContent
         */
        public function makeEmptyContent() {
-               return new JSONContent( '' );
+               return new $this->contentClass( '' );
        }
 
        /** JSON is English **/