Reference Source
import ExtensionData from 'flarum/utils/ExtensionData'
public class | source

ExtensionData

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public

data: {}

Method Summary

Public Methods
public

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

getPage(extension: *): boolean | *

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 Members

public currentExtension: * source

public data: {} source

Public Methods

public extensionHasPermissions(extension: *): boolean source

Checks whether a given extension has registered permissions.

Params:

NameTypeAttributeDescription
extension *

Return:

boolean

public for(extension: *): * source

This function simply takes the extension id

Params:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
extension *
type *

Return:

ItemList

public getExtensionPermissions(extension: *, type: *): boolean | * source

Get a singular extension's registered permissions

Params:

NameTypeAttributeDescription
extension *
type *

Return:

boolean | *

public getPage(extension: *): boolean | * source

Returns an extension's custom page component if it exists.

Params:

NameTypeAttributeDescription
extension *

Return:

boolean | *

public getSettings(extensionId: *): boolean | * source

Get an extension's registered settings

Params:

NameTypeAttributeDescription
extensionId *

Return:

boolean | *

public registerPage(component: *): ExtensionData source

Replace the default extension page with a custom component. This component would typically extend ExtensionPage

Params:

NameTypeAttributeDescription
component *

Return:

ExtensionData

public registerPermission(content: *, permissionType: *, priority: *): ExtensionData source

This function registers your permission with Flarum

Params:

NameTypeAttributeDescription
content *
permissionType *
priority *

Return:

ExtensionData

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:

NameTypeAttributeDescription
content *
priority *

Return:

ExtensionData

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)