The following methods in Content interface don't actually belong there. Content should be closer to a value object, and these methods are impossible in a value object:
- Content::getParserOutput
- Content::preSaveTransform
- Content::preLoadTransform
- Content::prepareSave
These methods need to move to new corresponding methods in ContentHandler. Here's a patch that does the first part of the work for Content::preSaveTransform
The signatures of the ContentHandler methods should be:
- ContentHandler::getParserOutput( Content, PageReference, ?int, ParserOptions, bool ) // TODO: discuss if generateHtml should be a new parser option
- ContentHandler::preSaveTransform( Content, PageReference, UserIdentity, ParserOptions )
- ContentHandler::preLoadTransform( Content, PageReference, ParserOptions, array )
- ContentHandler::prepareSave( Content, PageRecord, int, int, UserIdentity ) // TODO: discuss if PageRecord is needed or we can just do PageIdentity/Reference
You can create subtasks for each method to work on them individually, or just do all in here, up to you.
The process:
- Do the same as in the referenced patch for all the methods.
- In all extensions where Content overriding classes override the method - override the ContentHandler method instead
- Replace all callers. Use ContentHandlerFactory to obtain a ContentHandler, not the Content::getContentHandler method
- Once all callers and overrides in extensions is done, do some hard deprecations.