Merge "Use RemexHtml as the tidy implementation for parser tests"
[lhc/web/wiklou.git] / includes / content / TextContentHandler.php
index 748c810..4a7944c 100644 (file)
  */
 class TextContentHandler extends ContentHandler {
 
-       // @codingStandardsIgnoreStart bug 57585
        public function __construct( $modelId = CONTENT_MODEL_TEXT, $formats = [ CONTENT_FORMAT_TEXT ] ) {
                parent::__construct( $modelId, $formats );
        }
-       // @codingStandardsIgnoreEnd
 
        /**
         * Returns the content's text as-is.
         *
         * @param Content $content
-        * @param string  $format The serialization format to check
+        * @param string $format The serialization format to check
         *
         * @return mixed
         */
@@ -101,7 +99,7 @@ class TextContentHandler extends ContentHandler {
         * @return string
         */
        protected function getContentClass() {
-               return 'TextContent';
+               return TextContent::class;
        }
 
        /**
@@ -143,9 +141,22 @@ class TextContentHandler extends ContentHandler {
        }
 
        public function getFieldsForSearchIndex( SearchEngine $engine ) {
-               $fields = [];
+               $fields = parent::getFieldsForSearchIndex( $engine );
                $fields['language'] =
                        $engine->makeSearchFieldMapping( 'language', SearchIndexField::INDEX_TYPE_KEYWORD );
+
+               return $fields;
+       }
+
+       public function getDataForSearchIndex(
+               WikiPage $page,
+               ParserOutput $output,
+               SearchEngine $engine
+       ) {
+               $fields = parent::getDataForSearchIndex( $page, $output, $engine );
+               $fields['language'] =
+                       $this->getPageLanguage( $page->getTitle(), $page->getContent() )->getCode();
                return $fields;
        }
+
 }