Flarum (2.x)
    Preparing search index...

    Implements

    Index
    conditions: {
        condition: boolean | ((app: Application) => boolean);
        extenders: () => IExtender<any>[];
    }[] = []
    • Apply extenders based on a condition.

      Conditions are checked before the application boots, so app.forum and app.session aren't available yet. Use whenForumAttribute() to check a forum attribute.

      Parameters

      • condition: boolean | ((app: Application) => boolean)

        A boolean, or a callback returning a boolean.

      • extenders: () => IExtender<any>[]

        A callback returning an array of extenders.

      Returns this

      new Extend.Conditional()
      .when(
      () => 'flarum-tags' in flarum.extensions || 'flarum-mentions' in flarum.extensions,
      () => [new Extend.Model(Discussion).attribute<boolean>('acmeIsLinked')]
      )
    • Apply extenders only if an extension is disabled.

      Parameters

      • extensionId: string

        The ID of the extension.

      • extenders: () => IExtender<any>[]

        A callback returning an array of extenders.

      Returns this

      new Extend.Conditional()
      .whenExtensionDisabled('flarum-tags', () => [
      new Extend.Model(Discussion).attribute<string>('acmeCategoryLabel'),
      ])
    • Apply extenders only if an extension is enabled.

      Only extensions with JS for the current frontend can be detected.

      Parameters

      • extensionId: string

        The ID of the extension.

      • extenders: () => IExtender<any>[]

        A callback returning an array of extenders.

      Returns this

      new Extend.Conditional()
      .whenExtensionEnabled('flarum-tags', () => [
      new Extend.Model(Discussion).hasOne<Tag>('acmeFeaturedTag'),
      ])
    • Apply extenders only if all of the given extensions are disabled.

      Parameters

      • extensionIds: string[]

        The IDs of the extensions.

      • extenders: () => IExtender<any>[]

        A callback returning an array of extenders.

      Returns this

      new Extend.Conditional()
      .whenExtensionsDisabled(['flarum-tags', 'flarum-mentions'], () => [
      new Extend.Model(Discussion).attribute<string>('acmeCategoryLabel'),
      ])
    • Apply extenders only if all of the given extensions are enabled.

      Parameters

      • extensionIds: string[]

        The IDs of the extensions.

      • extenders: () => IExtender<any>[]

        A callback returning an array of extenders.

      Returns this

      new Extend.Conditional()
      .whenExtensionsEnabled(['flarum-tags', 'flarum-mentions'], () => [
      new Extend.Model(Discussion).attribute<boolean>('acmeMentionsTag'),
      ])
    • Apply extenders only if a forum attribute matches an expected value.

      Uses strict comparison (===). The value is read from the forum payload, as app.forum doesn't exist yet when extenders are applied.

      Parameters

      • key: string

        The name of the forum attribute.

      • expected: unknown

        The expected value.

      • extenders: () => IExtender<any>[]

        A callback returning an array of extenders.

      Returns this

      new Extend.Conditional()
      .whenForumAttribute('acmeAdvancedMode', true, () => [
      new Extend.Routes().add('acme.advanced', '/acme/advanced', AdvancedPage),
      ])