ExtensionData
Constructor Summary
Public Constructor | ||
public |
|
Member Summary
Public Members | ||
public |
|
|
public |
data: {} |
Method Summary
Public Methods | ||
public |
extensionHasPermissions(extension: *): boolean Checks whether a given extension has registered permissions. |
|
public |
for(extension: *): * This function simply takes the extension id |
|
public |
getAllExtensionPermissions(extension: *, type: *): ItemList Get an ItemList of all extensions' registered permissions |
|
public |
getExtensionPermissions(extension: *, type: *): boolean | * Get a singular extension's registered permissions |
|
public |
Returns an extension's custom page component if it exists. |
|
public |
getSettings(extensionId: *): boolean | * Get an extension's registered settings |
|
public |
registerPage(component: *): ExtensionData Replace the default extension page with a custom component. |
|
public |
registerPermission(content: *, permissionType: *, priority: *): ExtensionData This function registers your permission with Flarum |
|
public |
registerSetting(content: *, priority: *): ExtensionData This function registers your settings with Flarum |
Public Constructors
public constructor() source
Public Methods
public extensionHasPermissions(extension: *): boolean source
Checks whether a given extension has registered permissions.
Params:
Name | Type | Attribute | Description |
extension | * |
public for(extension: *): * source
This function simply takes the extension id
Params:
Name | Type | Attribute | Description |
extension | * |
Return:
* |
Example:
app.extensionData.load('flarum-tags')
flarum/flags -> flarum-flags | acme/extension -> acme-extension
public getAllExtensionPermissions(extension: *, type: *): ItemList source
Get an ItemList of all extensions' registered permissions
Params:
Name | Type | Attribute | Description |
extension | * | ||
type | * |
public getExtensionPermissions(extension: *, type: *): boolean | * source
Get a singular extension's registered permissions
Params:
Name | Type | Attribute | Description |
extension | * | ||
type | * |
public getPage(extension: *): boolean | * source
Returns an extension's custom page component if it exists.
Params:
Name | Type | Attribute | Description |
extension | * |
public getSettings(extensionId: *): boolean | * source
Get an extension's registered settings
Params:
Name | Type | Attribute | Description |
extensionId | * |
public registerPage(component: *): ExtensionData source
Replace the default extension page with a custom component. This component would typically extend ExtensionPage
Params:
Name | Type | Attribute | Description |
component | * |
public registerPermission(content: *, permissionType: *, priority: *): ExtensionData source
This function registers your permission with Flarum
Params:
Name | Type | Attribute | Description |
content | * | ||
permissionType | * | ||
priority | * |
Example:
.registerPermission('permissions', {
icon: 'fas fa-flag',
label: app.translator.trans('flarum-flags.admin.permissions.view_flags_label'),
permission: 'discussion.viewFlags'
}, 'moderate', 65)
public registerSetting(content: *, priority: *): ExtensionData source
This function registers your settings with Flarum
It takes either a settings object or a callback.
Params:
Name | Type | Attribute | Description |
content | * | ||
priority | * |
Example:
.registerSetting({
setting: 'flarum-flags.guidelines_url',
type: 'text', // This will be inputted into the input tag for the setting (text/number/etc)
label: app.translator.trans('flarum-flags.admin.settings.guidelines_url_label')
}, 15) // priority is optional (ItemList)