Merge "[MCR] Introduce SlotRoleHandler and SlotRoleRegistry"
[lhc/web/wiklou.git] / includes / Revision / RenderedRevision.php
index 6eee3c4..094105a 100644 (file)
@@ -159,6 +159,28 @@ class RenderedRevision implements SlotRenderingProvider {
                return $this->options;
        }
 
+       /**
+        * Sets a ParserOutput to be returned by getRevisionParserOutput().
+        *
+        * @note For internal use by RevisionRenderer only! This method may be modified
+        * or removed without notice per the deprecation policy.
+        *
+        * @internal
+        *
+        * @param ParserOutput $output
+        */
+       public function setRevisionParserOutput( ParserOutput $output ) {
+               $this->revisionOutput = $output;
+
+               // If there is only one slot, we assume that the combined output is identical
+               // with the main slot's output. This is intended to prevent a redundant re-parse of
+               // the content in case getSlotParserOutput( SlotRecord::MAIN ) is called, for instance
+               // from ContentHandler::getSecondaryDataUpdates.
+               if ( $this->revision->getSlotRoles() === [ SlotRecord::MAIN ] ) {
+                       $this->slotsOutput[ SlotRecord::MAIN ] = $output;
+               }
+       }
+
        /**
         * @param array $hints Hints given as an associative array. Known keys:
         *      - 'generate-html' => bool: Whether the caller is interested in output HTML (as opposed
@@ -208,6 +230,7 @@ class RenderedRevision implements SlotRenderingProvider {
                                        'Access to the content has been suppressed for this audience'
                                );
                        } else {
+                               // XXX: allow SlotRoleHandler to control the ParserOutput?
                                $output = $this->getSlotParserOutputUncached( $content, $withHtml );
 
                                if ( $withHtml && !$output->hasText() ) {