MediaWiki master
|
Base class for all Content objects. More...
Inherits MediaWiki\Content\Content.
Inherited by MediaWiki\Content\FallbackContent, and MediaWiki\Content\TextContent.
Public Member Functions | |
__construct ( $modelId=null) | |
addSectionHeader ( $header) | |
convert ( $toModel, $lossy='') | |
This base implementation calls the hook ConvertContent to enable custom conversions. | |
equals (?Content $that=null) | |
getContentHandler () | |
getDefaultFormat () | |
getModel () | |
getNativeData () | |
getRedirectTarget () | |
Subclasses that implement redirects should override this. | |
getSection ( $sectionId) | |
getSupportedFormats () | |
isEmpty () | |
isRedirect () | |
isSupportedFormat ( $format) | |
isValid () | |
matchMagicWord (MagicWord $word) | |
This default implementation always returns false. | |
replaceSection ( $sectionId, Content $with, $sectionTitle='') | |
serialize ( $format=null) | |
updateRedirect (Title $target) | |
This default implementation always returns $this. | |
![]() | |
copy () | |
Create a copy of this Content object. | |
getSize () | |
Get the content's nominal size in "bogo-bytes". | |
getTextForSearchIndex () | |
getTextForSummary ( $maxLength=250) | |
Get a textual representation of the content, suitable for use in edit summaries and log messages. | |
getWikitextForTransclusion () | |
isCountable ( $hasLinks=null) | |
Whether this content may count towards a "real" wiki page. | |
Protected Member Functions | |
checkFormat ( $format) | |
Helper for subclasses. | |
checkModelID ( $modelId) | |
Helper for subclasses. | |
equalsInternal (Content $that) | |
Helper for AbstractContent::equals. | |
getContentHandlerFactory () | |
Protected Attributes | |
string | $model_id |
Base class for all Content objects.
Refer to Content for more information.
Definition at line 38 of file AbstractContent.php.
MediaWiki\Content\AbstractContent::__construct | ( | $modelId = null | ) |
string | null | $modelId | One of the CONTENT_MODEL_XXX constants. |
Reimplemented in MediaWiki\Content\WikitextContent.
Definition at line 50 of file AbstractContent.php.
MediaWiki\Content\AbstractContent::addSectionHeader | ( | $header | ) |
string | $header |
Implements MediaWiki\Content\Content.
Reimplemented in MediaWiki\Content\WikitextContent.
Definition at line 302 of file AbstractContent.php.
|
protected |
Helper for subclasses.
string | $format | The serialization format to check. |
MWException | If the format is not supported by this Content object |
Definition at line 130 of file AbstractContent.php.
|
protected |
Helper for subclasses.
string | $modelId | The model to check |
MWException | If the provided model ID differs from this Content object |
Definition at line 70 of file AbstractContent.php.
Referenced by MediaWiki\Content\TextContent\diff().
MediaWiki\Content\AbstractContent::convert | ( | $toModel, | |
$lossy = '' ) |
This base implementation calls the hook ConvertContent to enable custom conversions.
Subclasses may override this to implement conversion for "their" content model.
string | $toModel | |
string | $lossy |
Implements MediaWiki\Content\Content.
Reimplemented in MediaWiki\Content\FallbackContent, and MediaWiki\Content\TextContent.
Definition at line 330 of file AbstractContent.php.
References MediaWiki\MediaWikiServices\getInstance().
MediaWiki\Content\AbstractContent::equals | ( | ?Content | $that = null | ) |
Content | null | $that |
Implements MediaWiki\Content\Content.
Definition at line 190 of file AbstractContent.php.
Referenced by MediaWiki\Content\CssContent\getRedirectTarget().
|
protected |
Helper for AbstractContent::equals.
This method can be overwritten by subclasses that only need to implement custom equality checks, with the rest of the Content::equals contract taken care of by AbstractContent::equals.
This default implementation compares Content::serialize of each object.
If you override this method, you can safely assume that $that is an instance of the same class as the current Content object. This is ensured by AbstractContent::equals.
Content | $that |
Reimplemented in MediaWiki\Content\FallbackContent.
Definition at line 230 of file AbstractContent.php.
References MediaWiki\Content\Content\serialize().
MediaWiki\Content\AbstractContent::getContentHandler | ( | ) |
Implements MediaWiki\Content\Content.
Reimplemented in MediaWiki\Content\WikitextContent.
Definition at line 83 of file AbstractContent.php.
References MediaWiki\Content\AbstractContent\getContentHandlerFactory(), and MediaWiki\Content\AbstractContent\getModel().
Referenced by MediaWiki\Content\CssContent\getRedirectTarget(), MediaWiki\Content\JavaScriptContent\getRedirectTarget(), MediaWiki\Content\CssContent\updateRedirect(), and MediaWiki\Content\JavaScriptContent\updateRedirect().
|
protected |
Definition at line 87 of file AbstractContent.php.
Referenced by MediaWiki\Content\TextContent\convert(), and MediaWiki\Content\AbstractContent\getContentHandler().
MediaWiki\Content\AbstractContent::getDefaultFormat | ( | ) |
Implements MediaWiki\Content\Content.
Definition at line 96 of file AbstractContent.php.
MediaWiki\Content\AbstractContent::getModel | ( | ) |
Implements MediaWiki\Content\Content.
Definition at line 59 of file AbstractContent.php.
References MediaWiki\Content\AbstractContent\$model_id.
Referenced by MediaWiki\Content\AbstractContent\getContentHandler(), and MediaWiki\Content\WikitextContent\replaceSection().
MediaWiki\Content\AbstractContent::getNativeData | ( | ) |
Implements MediaWiki\Content\Content.
Reimplemented in MediaWiki\Content\FallbackContent, and MediaWiki\Content\TextContent.
Definition at line 158 of file AbstractContent.php.
References wfDeprecated().
MediaWiki\Content\AbstractContent::getRedirectTarget | ( | ) |
Subclasses that implement redirects should override this.
Implements MediaWiki\Content\Content.
Reimplemented in MediaWiki\Content\CssContent, MediaWiki\Content\JavaScriptContent, and MediaWiki\Content\WikitextContent.
Definition at line 242 of file AbstractContent.php.
MediaWiki\Content\AbstractContent::getSection | ( | $sectionId | ) |
string | int | $sectionId |
Implements MediaWiki\Content\Content.
Reimplemented in MediaWiki\Content\WikitextContent.
Definition at line 277 of file AbstractContent.php.
MediaWiki\Content\AbstractContent::getSupportedFormats | ( | ) |
Implements MediaWiki\Content\Content.
Definition at line 105 of file AbstractContent.php.
MediaWiki\Content\AbstractContent::isEmpty | ( | ) |
Implements MediaWiki\Content\Content.
Definition at line 169 of file AbstractContent.php.
MediaWiki\Content\AbstractContent::isRedirect | ( | ) |
Implements MediaWiki\Content\Content.
Definition at line 251 of file AbstractContent.php.
Referenced by MediaWiki\Content\TextContent\isCountable(), MediaWiki\Content\WikitextContent\isCountable(), MediaWiki\Content\CssContent\updateRedirect(), MediaWiki\Content\JavaScriptContent\updateRedirect(), and MediaWiki\Content\WikitextContent\updateRedirect().
MediaWiki\Content\AbstractContent::isSupportedFormat | ( | $format | ) |
string | $format |
Implements MediaWiki\Content\Content.
Definition at line 115 of file AbstractContent.php.
MediaWiki\Content\AbstractContent::isValid | ( | ) |
Implements MediaWiki\Content\Content.
Reimplemented in MediaWiki\Content\JsonContent.
Definition at line 179 of file AbstractContent.php.
MediaWiki\Content\AbstractContent::matchMagicWord | ( | MagicWord | $word | ) |
This default implementation always returns false.
Subclasses may override this to supply matching logic.
MagicWord | $word |
Implements MediaWiki\Content\Content.
Reimplemented in MediaWiki\Content\WikitextContent.
Definition at line 316 of file AbstractContent.php.
MediaWiki\Content\AbstractContent::replaceSection | ( | $sectionId, | |
Content | $with, | ||
$sectionTitle = '' ) |
string | int | null | false | $sectionId | |
Content | $with | |
string | $sectionTitle |
Implements MediaWiki\Content\Content.
Reimplemented in MediaWiki\Content\WikitextContent.
Definition at line 291 of file AbstractContent.php.
MediaWiki\Content\AbstractContent::serialize | ( | $format = null | ) |
string | null | $format |
Implements MediaWiki\Content\Content.
Reimplemented in MediaWiki\Content\FallbackContent.
Definition at line 146 of file AbstractContent.php.
MediaWiki\Content\AbstractContent::updateRedirect | ( | Title | $target | ) |
This default implementation always returns $this.
Subclasses that implement redirects should override this.
Title | $target |
Implements MediaWiki\Content\Content.
Reimplemented in MediaWiki\Content\CssContent, MediaWiki\Content\JavaScriptContent, and MediaWiki\Content\WikitextContent.
Definition at line 266 of file AbstractContent.php.
|
protected |
Definition at line 43 of file AbstractContent.php.
Referenced by MediaWiki\Content\FallbackContent\__construct(), MediaWiki\Content\TextContent\__construct(), and MediaWiki\Content\AbstractContent\getModel().