Merge "Fix MediaWikiPageLinkRendererTest failing in non-English setups"
[lhc/web/wiklou.git] / includes / content / ContentHandler.php
index defa7da..e077c77 100644 (file)
@@ -430,6 +430,20 @@ abstract class ContentHandler {
         */
        abstract public function serializeContent( Content $content, $format = null );
 
+       /**
+        * Applies transformations on export (returns the blob unchanged per default).
+        * Subclasses may override this to perform transformations such as conversion
+        * of legacy formats or filtering of internal meta-data.
+        *
+        * @param string $blob The blob to be exported
+        * @param string|null $format The blob's serialization format
+        *
+        * @return string
+        */
+       public function exportTransform( $blob, $format = null ) {
+               return $blob;
+       }
+
        /**
         * Unserializes a Content object of the type supported by this ContentHandler.
         *
@@ -442,6 +456,21 @@ abstract class ContentHandler {
         */
        abstract public function unserializeContent( $blob, $format = null );
 
+       /**
+        * Apply import transformation (per default, returns $blob unchanged).
+        * This gives subclasses an opportunity to transform data blobs on import.
+        *
+        * @since 1.24
+        *
+        * @param string $blob
+        * @param string|null $format
+        *
+        * @return string
+        */
+       public function importTransform( $blob, $format = null ) {
+               return $blob;
+       }
+
        /**
         * Creates an empty Content object of the type supported by this
         * ContentHandler.
@@ -454,7 +483,7 @@ abstract class ContentHandler {
 
        /**
         * Creates a new Content object that acts as a redirect to the given page,
-        * or null of redirects are not supported by this content model.
+        * or null if redirects are not supported by this content model.
         *
         * This default implementation always returns null. Subclasses supporting redirects
         * must override this method.