Manual:Content.php
Appearance
MediaWiki file: Content.php | |
---|---|
Location: | includes/content/ |
Source code: | master • 1.42.3 • 1.41.4 • 1.39.10 |
Classes: | MediaWiki\Content\Content |
Content.php contains the Content interface, the base interface for content objects. A content object represents page content, e.g. the text to show on a page. Content objects have no knowledge about how they relate to wiki pages.
Instantiation
[edit]- ContentHandler::makeContent() - create a Content object from given textual representation. Text will be deserialized according to given content model.
Retrieval
[edit]- RevisionRecord::getContent() - get the Content object from a page revision.
Transformation
[edit]If you have access to a Content object but need to transform it before saving or on page preload.
- ContentTransformer::preSaveTransform() - return a Content object with pre-save transformations applied, or default content if no transformations apply.
- ContentTransformer::preloadTransform() - return a Content object with preload transformations applied, or again default content if no transformations apply. Before 1.37, this method was available in the Content class.
- ContentHandler::preloadTransform() - return a Content object with preload transformations applied, or again default content if no transformations apply.
Methods
[edit]- getTextForSearchIndex()
- getWikitextForTransclusion()
- getTextForSummary()
- getSize()
- getModel()
- getContentHandler()
- getDefaultFormat()
- getSupportedFormats()
- isSupportedFormat()
- serialize()
- isEmpty()
- isValid()
- equals()
- copy()
- isCountable()
- getRedirectTarget()
- isRedirect()
- updateRedirect()
- getSection()
- replaceSection()
- addSectionHeader()
- matchMagicWord()
- convert()
Deprecated or removed
[edit]- getNativeData() - use getText() for TextContent instances. Use specialized getters for other content models.
- prepareSave() - use ContentHandler::validateSave .
- getParserOutput() - use ContentRenderer::getParserOutput
- Now part of ContentTransformer : preSaveTransform() (use ContentTransformer::preSaveTransform), preloadTransform() (use ContentTransformer::preloadTransform).
Implemented by
[edit]- Manual:AbstractContent.php - base implementation, which is extended by other classes such as TextContent , which is in turn extended by WikitextContent .