class Frontend implements ExtenderInterface

Methods

__construct(string $frontend)

No description

css(string $path)

Add a CSS file to load in the frontend.

js(string $path)

Add a JavaScript file to load in the frontend.

route(string $path, string $name, callable|string|null $content = null)

Add a route to the frontend.

removeRoute(string $name)

Remove a route from the frontend.

content($callback)

Modify the content of the frontend.

preloads(callable|array $preloads)

Adds multiple asset preloads.

title(string $driverClass)

Register a new title driver to change the title of frontend documents.

extend(Container $container, Extension $extension = null)

No description

Details

__construct(string $frontend)

Parameters

string $frontend

Frontend css(string $path)

Add a CSS file to load in the frontend.

Parameters

string $path

Return Value

Frontend

Frontend js(string $path)

Add a JavaScript file to load in the frontend.

Parameters

string $path

Return Value

Frontend

Frontend route(string $path, string $name, callable|string|null $content = null)

Add a route to the frontend.

Parameters

string $path
string $name
callable|string|null $content The content can be a closure or an invokable class, and should accept: - \Flarum\Frontend\Document $document - \Psr\Http\Message\ServerRequestInterface $request The callable should return void.

Return Value

Frontend

Frontend removeRoute(string $name)

Remove a route from the frontend.

This is necessary before overriding a route.

Parameters

string $name

Return Value

Frontend

Frontend content($callback)

Modify the content of the frontend.

Parameters

$callback

Return Value

Frontend

Frontend preloads(callable|array $preloads)

Adds multiple asset preloads.

The parameter should be an array of preload arrays, or a callable that returns this. A preload array must contain keys that pertain to the `<link rel="preload">` tag. For example, the following will add preload tags for a script and font file: ``` $frontend->preloads([ [ 'href' => '/assets/my-script.js', 'as' => 'script', ], [ 'href' => '/assets/fonts/my-font.woff2', 'as' => 'font', 'type' => 'font/woff2', 'crossorigin' => '' ] ]); ```

Parameters

callable|array $preloads

Return Value

Frontend

Frontend title(string $driverClass)

Register a new title driver to change the title of frontend documents.

Parameters

string $driverClass

Return Value

Frontend

extend(Container $container, Extension $extension = null)

Parameters

Container $container
Extension $extension