Core
Framework v2.x
2

roles() #

Available since 2.14.0

Loads roles into the app.

This method is idempotent. If a role is defined multiple times, only the last definition will be retained.

This method can only be used before the application is started.

roles(roles: JSONObject): void

ArgumentTypeDescription
roles
JSONObject
Object containing roles and their definitions.

Usage #

app.import.roles({
  roleA: {
    controllers: {
      controllerA: {
        actions: {
          actionA: true,
          actionB: false,
        }
      },
      controllerB: {
        actions: {
          '*': true
        }
      },
    }
  },
  roleB: {
    controllers: {
      '*': {
        actions: {
          '*': true
        }
      }
    },
  },
})