class Frontend implements ExtenderInterface

Methods

__construct(string $frontend)

No description

css(string $path)

<p>Add a CSS file to load in the frontend.</p>

js(string $path)

<p>Add a JavaScript file to load in the frontend.</p>

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

<p>Add a route to the frontend.</p>

removeRoute(string $name)

<p>Remove a route from the frontend.</p>

content(callable|string|null $callback)

<p>Modify the content of the frontend.</p>

preloads(callable|array $preloads)

<p>Adds multiple asset preloads.</p>

title(string $driverClass)

<p>Register a new title driver to change the title of frontend documents.</p>

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

No description

Details

__construct(string $frontend)

Parameters

string $frontend

Frontend css(string $path)

<p>Add a CSS file to load in the frontend.</p>

Parameters

string $path

Return Value

Frontend

Frontend js(string $path)

<p>Add a JavaScript file to load in the frontend.</p>

Parameters

string $path

Return Value

Frontend

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

<p>Add a route to the frontend.</p>

Parameters

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

Return Value

Frontend

Frontend removeRoute(string $name)

<p>Remove a route from the frontend.</p>

<p>This is necessary before overriding a route.</p>

Parameters

string $name

Return Value

Frontend

Frontend content(callable|string|null $callback)

<p>Modify the content of the frontend.</p>

Parameters

callable|string|null $callback <p>The content can be a closure or an invokable class, and should accept:</p> <ul> <li>\Flarum\Frontend\Document $document</li> <li>\Psr\Http\Message\ServerRequestInterface $request</li> </ul> <p>The callable should return void.</p>

Return Value

Frontend

Frontend preloads(callable|array $preloads)

<p>Adds multiple asset preloads.</p>

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

Parameters

callable|array $preloads

Return Value

Frontend

Frontend title(string $driverClass)

<p>Register a new title driver to change the title of frontend documents.</p>

Parameters

string $driverClass

Return Value

Frontend

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

Parameters

Container $container
Extension $extension