From be2a2c681acdbb407faa785f27a410ffffcf1fb6 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Sat, 9 Aug 2014 00:51:19 +0100 Subject: [PATCH] Let subclasses specify their associated content class for JSONContentHandler Also add @since tags and release notes Change-Id: I515a51f40b7820a3d45b1219d21923467abe5ecd --- RELEASE-NOTES-1.24 | 1 + includes/content/JSONContent.php | 1 + includes/content/JSONContentHandler.php | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24 index ae2ab4f5ef..d68d5295ab 100644 --- a/RELEASE-NOTES-1.24 +++ b/RELEASE-NOTES-1.24 @@ -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 diff --git a/includes/content/JSONContent.php b/includes/content/JSONContent.php index 0fa9282241..16bb27933d 100644 --- a/includes/content/JSONContent.php +++ b/includes/content/JSONContent.php @@ -10,6 +10,7 @@ /** * Represents the content of a JSON content. + * @since 1.24 */ class JSONContent extends TextContent { diff --git a/includes/content/JSONContentHandler.php b/includes/content/JSONContentHandler.php index b290fb2aa1..9d001da1c8 100644 --- a/includes/content/JSONContentHandler.php +++ b/includes/content/JSONContentHandler.php @@ -8,8 +8,18 @@ * @author Kunal Mehta */ +/** + * @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 **/ -- 2.20.1