abstract class AbstractClientController extends AbstractHtmlController

This action sets up a ClientView, and preloads it with the assets necessary to boot a Flarum client.

Subclasses should set a $clientName, $layout, and $translationKeys. The client name will be used to locate the client assets (or alternatively, subclasses can overwrite the addAssets method), and set up asset compilers which write to the assets directory. Configured LESS customizations will be appended.

A locale compiler is set up for the actor's locale, including the translations specified in $translationKeys. Additionally, an event is fired before the ClientView is returned, giving extensions an opportunity to add assets, translations, or alter the view.

Properties

protected string $clientName <p>The name of the client. This is used to locate assets within the js/ and less/ directories. It is also used as the filename of the compiled asset files.</p>
protected string $layout <p>The name of the view to include as the page layout.</p>
protected string $translations <p>A regex matching the keys of the translations that should be included in the compiled locale file.</p>
protected Application $app
protected Client $api
protected LocaleManager $locales
protected SettingsRepositoryInterface $settings
protected Dispatcher $events
protected Repository $cache

Methods

ResponseInterface
handle(ServerRequestInterface $request)

No description

Renderable
render(ServerRequestInterface $request)

No description

__construct(Application $app, Client $api, LocaleManager $locales, SettingsRepositoryInterface $settings, Dispatcher $events, Repository $cache)

No description

flushAssets()

<p>Flush the client's assets so that they will be regenerated from scratch on the next render.</p>

flushCss()

No description

flushJs()

No description

flushLocales()

No description

getAssets()

<p>Set up the asset manager, preloaded with a JavaScript compiler and a LESS compiler. Automatically add the files necessary to boot a Flarum client, as well as any configured LESS customizations.</p>

addAssets(AssetManager $assets)

<p>Add the assets necessary to boot a Flarum client, found within the directory specified by the $clientName property.</p>

addCustomizations(AssetManager $assets)

<p>Add any configured JS/LESS customizations to the asset manager.</p>

array
getLessVariables()

<p>Get the values of any LESS variables to compile into the CSS, based on the forum's configuration.</p>

getLocaleCompiler(string $locale)

<p>Set up the locale compiler for the given locale.</p>

string
getAssetDirectory()

<p>Get the path to the directory where assets should be written.</p>

array
filterTranslations(array $translations)

<p>Take a selection of keys from a collection of translations.</p>

Details

ResponseInterface handle(ServerRequestInterface $request)

Parameters

ServerRequestInterface $request

Return Value

ResponseInterface

Renderable render(ServerRequestInterface $request)

Parameters

ServerRequestInterface $request

Return Value

Renderable

__construct(Application $app, Client $api, LocaleManager $locales, SettingsRepositoryInterface $settings, Dispatcher $events, Repository $cache)

Parameters

Application $app
Client $api
LocaleManager $locales
SettingsRepositoryInterface $settings
Dispatcher $events
Repository $cache

flushAssets()

<p>Flush the client's assets so that they will be regenerated from scratch on the next render.</p>

flushCss()

flushJs()

flushLocales()

protected AssetManager getAssets()

<p>Set up the asset manager, preloaded with a JavaScript compiler and a LESS compiler. Automatically add the files necessary to boot a Flarum client, as well as any configured LESS customizations.</p>

Return Value

AssetManager

protected addAssets(AssetManager $assets)

<p>Add the assets necessary to boot a Flarum client, found within the directory specified by the $clientName property.</p>

Parameters

AssetManager $assets

protected addCustomizations(AssetManager $assets)

<p>Add any configured JS/LESS customizations to the asset manager.</p>

Parameters

AssetManager $assets

protected array getLessVariables()

<p>Get the values of any LESS variables to compile into the CSS, based on the forum's configuration.</p>

Return Value

array

protected JsCompiler getLocaleCompiler(string $locale)

<p>Set up the locale compiler for the given locale.</p>

Parameters

string $locale

Return Value

JsCompiler

protected string getAssetDirectory()

<p>Get the path to the directory where assets should be written.</p>

Return Value

string

protected array filterTranslations(array $translations)

<p>Take a selection of keys from a collection of translations.</p>

Parameters

array $translations

Return Value

array