class Theme implements ExtenderInterface
Methods
This can be used to override LESS files that are imported within the code.
This method allows overriding LESS file sources.
This method allows you to add custom Less functions.
Defines a new Less variable to be accessible in all Less files.
Details
at
line 34
Theme
overrideLessImport(string $file, string $newFilePath, string $extensionId = null)
This can be used to override LESS files that are imported within the code.
For example, core's `forum.less` file imports a `forum/DiscussionListItem.less` file. The contents of this file can be overriden with this method.
at
line 51
Theme
overrideFileSource(string $file, string $newFilePath, string $extensionId = null)
This method allows overriding LESS file sources.
For example `forum.less`, `admin.less`, `mixins.less` and `variables.less` are file sources, and can therefore be overriden using this method.
at
line 77
Theme
addCustomLessFunction(string $functionName, callable $callable)
This method allows you to add custom Less functions.
All custom Less functions may only return numbers, strings or booleans. **Example usage:** ```php (new Extend\Theme) ->addCustomLessFunction('is-flarum', function (mixed $text) { return strtolower($text) === 'flarum' }), ```
at
line 132
Theme
addCustomLessVariable(string $variableName, callable $value)
Defines a new Less variable to be accessible in all Less files.
If you want to expose a setting from your database to Less, you should use the `registerLessConfigVar` extender from `Extend\Settings` instead. 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. Likewise, if you need your variable to be a string, you should surround it with quotes yourself. ```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\""; }) ```