diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:12:12 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:12:12 -0400 |
commit | c9aa36da061816dee256a979c2ff8d2ee41824d9 (patch) | |
tree | 29f7002b80ee984b488bd047dbbd80b36bf892e9 /includes/content/TextContentHandler.php | |
parent | b4274e0e33eafb5e9ead9d949ebf031a9fb8363b (diff) | |
parent | d1ba966140d7a60cd5ae4e8667ceb27c1a138592 (diff) |
Merge branch 'archwiki'
# Conflicts:
# skins/ArchLinux.php
# skins/ArchLinux/archlogo.gif
Diffstat (limited to 'includes/content/TextContentHandler.php')
-rw-r--r-- | includes/content/TextContentHandler.php | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/includes/content/TextContentHandler.php b/includes/content/TextContentHandler.php index e7f41e18..ffe1acbd 100644 --- a/includes/content/TextContentHandler.php +++ b/includes/content/TextContentHandler.php @@ -30,19 +30,24 @@ */ class TextContentHandler extends ContentHandler { - public function __construct( $modelId = CONTENT_MODEL_TEXT, $formats = array( CONTENT_FORMAT_TEXT ) ) { + // @codingStandardsIgnoreStart bug 57585 + public function __construct( $modelId = CONTENT_MODEL_TEXT, + $formats = array( CONTENT_FORMAT_TEXT ) ) { parent::__construct( $modelId, $formats ); } + // @codingStandardsIgnoreEnd /** * Returns the content's text as-is. * - * @param $content Content - * @param $format string|null + * @param Content $content + * @param string $format The serialization format to check + * * @return mixed */ public function serializeContent( Content $content, $format = null ) { $this->checkFormat( $format ); + return $content->getNativeData(); } @@ -55,11 +60,11 @@ class TextContentHandler extends ContentHandler { * * This text-based implementation uses wfMerge(). * - * @param $oldContent Content|string String - * @param $myContent Content|string String - * @param $yourContent Content|string String + * @param Content $oldContent The page's previous content. + * @param Content $myContent One of the page's conflicting contents. + * @param Content $yourContent One of the page's conflicting contents. * - * @return Content|Bool + * @return Content|bool */ public function merge3( Content $oldContent, Content $myContent, Content $yourContent ) { $this->checkModelID( $oldContent->getModel() ); @@ -83,23 +88,38 @@ class TextContentHandler extends ContentHandler { } $mergedContent = $this->unserializeContent( $result, $format ); + return $mergedContent; } /** + * Returns the name of the associated Content class, to + * be used when creating new objects. Override expected + * by subclasses. + * + * @since 1.24 + * + * @return string + */ + protected function getContentClass() { + return 'TextContent'; + } + + /** * Unserializes a Content object of the type supported by this ContentHandler. * * @since 1.21 * - * @param $text string serialized form of the content - * @param $format null|String the format used for serialization + * @param string $text Serialized form of the content + * @param string $format The format used for serialization * - * @return Content the TextContent object wrapping $text + * @return Content The TextContent object wrapping $text */ public function unserializeContent( $text, $format = null ) { $this->checkFormat( $format ); - return new TextContent( $text ); + $class = $this->getContentClass(); + return new $class( $text ); } /** @@ -107,9 +127,11 @@ class TextContentHandler extends ContentHandler { * * @since 1.21 * - * @return Content + * @return Content A new TextContent object with empty text. */ public function makeEmptyContent() { - return new TextContent( '' ); + $class = $this->getContentClass(); + return new $class( '' ); } + } |