class Theme implements ExtenderInterface
Methods
<p>This can be used to override <code>LESS</code> files that are imported within the code.</p>
<p>This method allows overriding LESS file sources.</p>
<p>This method allows you to add custom Less functions.</p>
<p>Defines a new Less variable to be accessible in all Less files.</p>
Details
at
line 34
Theme
overrideLessImport(string $file, string $newFilePath, string|null $extensionId = null)
<p>This can be used to override <code>LESS</code> files that are imported within the code.</p>
<p>For example, core's <code>forum.less</code> file imports a <code>forum/DiscussionListItem.less</code> file. The contents of this file can be overriden with this method.</p>
at
line 51
Theme
overrideFileSource(string $file, string $newFilePath, string $extensionId = null)
<p>This method allows overriding LESS file sources.</p>
<p>For example <code>forum.less</code>, <code>admin.less</code>, <code>mixins.less</code> and <code>variables.less</code> are file sources, and can therefore be overriden using this method.</p>
at
line 77
Theme
addCustomLessFunction(string $functionName, callable $callable)
<p>This method allows you to add custom Less functions.</p>
<p>All custom Less functions may only return numbers, strings or booleans.</p> <p><strong>Example usage:</strong></p> <pre><code class="language-php">(new Extend\Theme) ->addCustomLessFunction('is-flarum', function (mixed $text) { return strtolower($text) === 'flarum' }),</code></pre>
at
line 132
Theme
addCustomLessVariable(string $variableName, callable $value)
<p>Defines a new Less variable to be accessible in all Less files.</p>
<p>If you want to expose a setting from your database to Less, you should use the <code>registerLessConfigVar</code> extender from <code>Extend\Settings</code> instead.</p> <p>Please note the value returned from the callable will be inserted directly into the Less source. If it is unsafe in some way (e.g., contains a semi-colon), this will result in potential security issues with your stylesheet.</p> <p>Likewise, if you need your variable to be a string, you should surround it with quotes yourself.</p> <pre><code class="language-php">(new Extend\Theme()) ->addCustomLessVariable('my-extension__asset_path', function () { $url = resolve(UrlGenerator::class); $assetUrl = $url->to('forum')->base().'/assets/extensions/my-extension/my-asset.jpg'; return "\"$assetUrl\""; })</code></pre>