class ClientView implements Renderable

This class represents a view which boots up Flarum's client.

Properties

protected User $actor <p>The user who is using the client.</p>
protected null|string $title <p>The title of the document, displayed in the <title> tag.</p>
protected string $content <p>The SEO content of the page, displayed in <noscript> tags.</p>
protected string $layout <p>The path to the client layout view to display.</p>
protected null|array|object $document <p>An API response that should be preloaded into the page.</p>
protected array $variables <p>Other variables to preload into the page.</p>
protected array $bootstrappers <p>An array of JS modules to import before booting the app.</p>
protected array $headStrings <p>An array of strings to append to the page's <head>.</p>
protected array $footStrings <p>An array of strings to prepend before the page's </body>.</p>
protected Client $api
protected ServerRequestInterface $request
protected AssetManager $assets
protected JsCompiler $localeJs

Methods

__construct(Client $api, ServerRequestInterface $request, User $actor, AssetManager $assets, string $layout, JsCompiler $localeJs = null)

No description

setTitle(null|string $title)

<p>The title of the document, to be displayed in the <title> tag.</p>

setContent(null|string $content)

<p>Set the SEO content of the page, to be displayed in <noscript> tags.</p>

setLayout(string $layout)

<p>Set the name of the client layout view to display.</p>

addHeadString(string $string)

<p>Add a string to be appended to the page's <head>.</p>

addFootString(string $string)

<p>Add a string to be prepended before the page's </body>.</p>

setDocument(null|array|object $document)

<p>Set an API response to be preloaded into the page. This should be a JSON-API document.</p>

setVariable(string $name, mixed $value)

<p>Set a variable to be preloaded into the app.</p>

addBootstrapper(string $string)

<p>Add a JavaScript module to be imported before the app is booted.</p>

getAssets()

<p>Get the view's asset manager.</p>

string
render()

<p>Get the string contents of the view.</p>

string
__toString()

<p>Get the string contents of the view.</p>

object
getForumDocument()

<p>Get the result of an API request to show the forum.</p>

object
getUserDocument()

<p>Get the result of an API request to show the current user.</p>

array
getDataFromDocument(object $document)

<p>Get an array of data by merging the 'data' and 'included' keys of a JSON-API document.</p>

array
getSession()

<p>Get information about the current session.</p>

Details

__construct(Client $api, ServerRequestInterface $request, User $actor, AssetManager $assets, string $layout, JsCompiler $localeJs = null)

Parameters

Client $api
ServerRequestInterface $request
User $actor
AssetManager $assets
string $layout
JsCompiler $localeJs

setTitle(null|string $title)

<p>The title of the document, to be displayed in the <title> tag.</p>

Parameters

null|string $title

setContent(null|string $content)

<p>Set the SEO content of the page, to be displayed in <noscript> tags.</p>

Parameters

null|string $content

setLayout(string $layout)

<p>Set the name of the client layout view to display.</p>

Parameters

string $layout

addHeadString(string $string)

<p>Add a string to be appended to the page's <head>.</p>

Parameters

string $string

addFootString(string $string)

<p>Add a string to be prepended before the page's </body>.</p>

Parameters

string $string

setDocument(null|array|object $document)

<p>Set an API response to be preloaded into the page. This should be a JSON-API document.</p>

Parameters

null|array|object $document

setVariable(string $name, mixed $value)

<p>Set a variable to be preloaded into the app.</p>

Parameters

string $name
mixed $value

addBootstrapper(string $string)

<p>Add a JavaScript module to be imported before the app is booted.</p>

Parameters

string $string

AssetManager getAssets()

<p>Get the view's asset manager.</p>

Return Value

AssetManager

string render()

<p>Get the string contents of the view.</p>

Return Value

string

string __toString()

<p>Get the string contents of the view.</p>

Return Value

string

protected object getForumDocument()

<p>Get the result of an API request to show the forum.</p>

Return Value

object

protected object getUserDocument()

<p>Get the result of an API request to show the current user.</p>

Return Value

object

protected array getDataFromDocument(object $document)

<p>Get an array of data by merging the 'data' and 'included' keys of a JSON-API document.</p>

Parameters

object $document

Return Value

array

protected array getSession()

<p>Get information about the current session.</p>

Return Value

array