Wctaiwan has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/154451

Change subject: Subclass JSONContent
......................................................................

Subclass JSONContent

Change-Id: I766e7c3c443c84367d301204deed3fda61d7e73f
---
M includes/content/MassMessageListContent.php
M includes/content/MassMessageListContentHandler.php
2 files changed, 9 insertions(+), 32 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage 
refs/changes/51/154451/1

diff --git a/includes/content/MassMessageListContent.php 
b/includes/content/MassMessageListContent.php
index 15f9630..c207ac3 100644
--- a/includes/content/MassMessageListContent.php
+++ b/includes/content/MassMessageListContent.php
@@ -1,6 +1,6 @@
 <?php
 
-class MassMessageListContent extends TextContent {
+class MassMessageListContent extends JSONContent {
 
        /**
         * Description wikitext
@@ -69,20 +69,6 @@
        }
 
        /**
-        * Returns a list content object with pre-save transformations applied.
-        * The implementation normalizes the JSON data.
-        * @param Title $title
-        * @param User $user
-        * @param ParserOptions $popts
-        * @return MassMessageListContent
-        */
-       public function preSaveTransform( Title $title, User $user, 
ParserOptions $popts ) {
-               $text = $this->getNativeData();
-               $pst = FormatJson::encode( FormatJson::decode( $text ) );
-               return ( $text === $pst ) ? $this : new static( $pst );
-       }
-
-       /**
         * @return string|null
         */
        public function getDescription() {
@@ -147,7 +133,7 @@
                if ( $this->decoded ) {
                        return;
                }
-               $data = FormatJson::decode( $this->getNativeData(), true );
+               $data = $this->getJsonData();
                if ( is_array( $data ) ) {
                        $this->description = array_key_exists( 'description', 
$data ) ?
                                $data['description'] : null;
diff --git a/includes/content/MassMessageListContentHandler.php 
b/includes/content/MassMessageListContentHandler.php
index 4ecdda1..02ff1a8 100644
--- a/includes/content/MassMessageListContentHandler.php
+++ b/includes/content/MassMessageListContentHandler.php
@@ -1,26 +1,17 @@
 <?php
 
-class MassMessageListContentHandler extends TextContentHandler {
+class MassMessageListContentHandler extends JSONContentHandler {
+
+       /**
+        * @var string
+        */
+       protected $contentClass = 'MassMessageListContent';
 
        /**
         * @param string $modelId
         */
        public function __construct( $modelId = 'MassMessageListContent' ) {
-               parent::__construct( $modelId, array( CONTENT_FORMAT_JSON ) );
-       }
-
-       /**
-        * @param string $text
-        * @param string $format
-        * @return MassMessageListContent
-        */
-       public function unserializeContent( $text, $format = null ) {
-               $this->checkFormat( $format );
-               $content = new MassMessageListContent( $text );
-               if ( !$content->isValid() ) {
-                       throw new MWContentSerializationException( 'The 
delivery list content is invalid.' );
-               }
-               return $content;
+               parent::__construct( $modelId );
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/154451
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I766e7c3c443c84367d301204deed3fda61d7e73f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MassMessage
Gerrit-Branch: contenthandler
Gerrit-Owner: Wctaiwan <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to