MediaWiki master
MediaWiki\Rest\Handler\Helper\HtmlShadowOutputHelper Class Reference

Inherits MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.

Collaboration diagram for MediaWiki\Rest\Handler\Helper\HtmlShadowOutputHelper:

Public Member Functions

 __construct (private ShadowPageLoader $shadowPageLoader, private TitleFormatter $titleFormatter, private SiteConfig $siteConfig, private ParserOptions $parserOptions, PageIdentity $page)
 
 getETag (string $suffix='')
 Returns an ETag uniquely identifying the HTML output.
See also
Handler::getETag()
Parameters
string$suffixA suffix to attach to the etag. Must consist of characters that are legal in ETags.
Returns
string|null We return null when there is no etag.

 
 getHtml ()
 Fetch the HTML for rendering of a given page.If the rendering is available in parsoid parser cache, return that. Otherwise, perform a parse and return the result while caching it in the parser cache.NOTE: Caching can be explicitly disabled or a force parse action can be issued. Stashing and rate limiting on stashing also applies here if specified.
Returns
ParserOutput a tuple with html and content-type
Exceptions
LocalizedHttpException
ClientError

 
 getLastModified ()
 Returns the time at which the HTML was rendered.
See also
Handler::getLastModified()
Returns
string|null

 
 getPageBundle ()
 Fetch the rendering of a given page as a full-document HtmlPageBundle.Unlike getHtml() (whose ParserOutput carries body-only content), the returned bundle always carries the full document (<html><head>…</head> <body>…</body></html>). Use this when emitting a full document to a client.
Returns
HtmlPageBundle
Exceptions
LocalizedHttpException
ClientError

 
 putHeaders (ResponseInterface $response, bool $forHtml=true)
 Set the HTTP headers based on the response generated.
 
 setVariantConversionLanguage ( $targetLanguage, $sourceLanguage=null)
 Set the language to be used for variant conversion.If $targetLanguage is a string, it may be a list of language ranges as specified by RFC 9110 for use in the Accept-Language header. Implementations must be able to process this format, and may use the information provided to choose a supported target language that is desirable to the client.
Parameters
Bcp47Code | string$targetLanguage
Bcp47Code | string | null$sourceLanguage

 

Static Public Member Functions

static getParamSettings ()
 Gets the request parameters of this request.
See also
Handler::getParamSettings()
Returns
array

 

Detailed Description

Since
1.47
Stability: unstable

Definition at line 24 of file HtmlShadowOutputHelper.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Rest\Handler\Helper\HtmlShadowOutputHelper::__construct ( private ShadowPageLoader $shadowPageLoader,
private TitleFormatter $titleFormatter,
private SiteConfig $siteConfig,
private ParserOptions $parserOptions,
PageIdentity $page )

Definition at line 29 of file HtmlShadowOutputHelper.php.

Member Function Documentation

◆ getETag()

MediaWiki\Rest\Handler\Helper\HtmlShadowOutputHelper::getETag ( string $suffix = '')

Returns an ETag uniquely identifying the HTML output.

See also
Handler::getETag()
Parameters
string$suffixA suffix to attach to the etag. Must consist of characters that are legal in ETags.
Returns
string|null We return null when there is no etag.

Implements MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.

Definition at line 83 of file HtmlShadowOutputHelper.php.

◆ getHtml()

MediaWiki\Rest\Handler\Helper\HtmlShadowOutputHelper::getHtml ( )

Fetch the HTML for rendering of a given page.If the rendering is available in parsoid parser cache, return that. Otherwise, perform a parse and return the result while caching it in the parser cache.NOTE: Caching can be explicitly disabled or a force parse action can be issued. Stashing and rate limiting on stashing also applies here if specified.

Returns
ParserOutput a tuple with html and content-type
Exceptions
LocalizedHttpException
ClientError

Implements MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.

Definition at line 42 of file HtmlShadowOutputHelper.php.

◆ getLastModified()

MediaWiki\Rest\Handler\Helper\HtmlShadowOutputHelper::getLastModified ( )

Returns the time at which the HTML was rendered.

See also
Handler::getLastModified()
Returns
string|null

Note
This is guaranteed to always return NULL since proper system messages (with no DB entry) have no revision, so they should have no last modified time.

Implements MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.

Definition at line 99 of file HtmlShadowOutputHelper.php.

◆ getPageBundle()

MediaWiki\Rest\Handler\Helper\HtmlShadowOutputHelper::getPageBundle ( )

Fetch the rendering of a given page as a full-document HtmlPageBundle.Unlike getHtml() (whose ParserOutput carries body-only content), the returned bundle always carries the full document (<html><head>…</head> <body>…</body></html>). Use this when emitting a full document to a client.

Returns
HtmlPageBundle
Exceptions
LocalizedHttpException
ClientError

Builds the full document directly as a page bundle: the body fragment from the shadow page wrapped in a document with an injected content-language <meta> in the <head>. (getHtml()'s ParserOutput stays body-only, per the ContentHolder invariant.)

Implements MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.

Definition at line 74 of file HtmlShadowOutputHelper.php.

◆ getParamSettings()

static MediaWiki\Rest\Handler\Helper\HtmlShadowOutputHelper::getParamSettings ( )
static

Gets the request parameters of this request.

See also
Handler::getParamSettings()
Returns
array

Implements MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.

Definition at line 106 of file HtmlShadowOutputHelper.php.

◆ putHeaders()

MediaWiki\Rest\Handler\Helper\HtmlShadowOutputHelper::putHeaders ( ResponseInterface $response,
bool $forHtml = true )

Set the HTTP headers based on the response generated.

Parameters
ResponseInterface$response
bool$forHtmlWhether the response will be HTML (rather than JSON)
Returns
void

Implements MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.

Definition at line 120 of file HtmlShadowOutputHelper.php.

◆ setVariantConversionLanguage()

MediaWiki\Rest\Handler\Helper\HtmlShadowOutputHelper::setVariantConversionLanguage ( $targetLanguage,
$sourceLanguage = null )

Set the language to be used for variant conversion.If $targetLanguage is a string, it may be a list of language ranges as specified by RFC 9110 for use in the Accept-Language header. Implementations must be able to process this format, and may use the information provided to choose a supported target language that is desirable to the client.

Parameters
Bcp47Code | string$targetLanguage
Bcp47Code | string | null$sourceLanguage

Implements MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.

Definition at line 113 of file HtmlShadowOutputHelper.php.


The documentation for this class was generated from the following file: