Role definition
The text-based role definition is the main purpose of this extension's funcionality. This brings the advantage to have the access definitions under version control and add the roll-out of new or updated definitions to a CI or a deployment system.
New in version 2.0
Starting with backend_roles 2.0 it is possible to store the role definitions in YAML files.
New in version 2.0
Starting with backend_roles 2.0 it is possible to store the role definitions in the global configuration directory.
Definitions file
Location
The role definitions are expected to be found in either of following locations:
-
Global
Location: the project's configuration directory
<project-
(orroot>/ config/ typo3conf/
in legacy installations).Filename
Backend
/Role Definitions. yaml Backend
Role Definitions. php -
Per extension
Location: an extension's configuration directory
<extension>/
.Configuration Filename
Backend
/Role Definitions. yaml Backend
Role Definitions. php
Note
Every such file that could be found by backend_roles will be interpreted as an independet role definitions file. It is not possible to overwrite role definitions from other sources.
The files are searched and loaded in the following order:
- Global
<project-
root>/ config/ Backend Role Definitions. yaml - Global
<project-
root>/ config/ Backend Role Definitions. php - Per extension
<extension>/
Configuration/ Backend Role Definitions. yaml - Per extension
<extension>/
Configuration/ Backend Role Definitions. php
Format
The role definitions can be stored as YAML or PHP files. YAML files MUST contain
an array Role
, PHP files just return a plain array.
RoleDefinitions:
-
identifier: role-basic
title: 'Basic role'
# ...
return [
[
'identifier' => 'role-basic',
'title' => 'Basic role',
// ...
],
];
Role definition options
The available options correspond 1:1 to the fields of the be_
record.
Except for identifier
and title
.
The documentation of the types/formats can be found below.
Option name | Type | Description |
---|---|---|
identifier | Text | Required. Used to identify the role
in a be_ record |
title | Text | Required. The title of the role is
shown in the role-selector in
be_ records |
TSconfig | Text | be_ |
pagetypes_ | Array | be_ |
tables_ | Array | be_ |
tables_ | Array | be_ |
group | Array | be_ |
tables_ | Array | be_ |
file_ | Array | be_ |
allowed_ | Array | be_ |
explicit_ | Multi-Array | be_ |
non_ | Multi-Array | be_ |
Types / Format
The option formats are meant to be as close as "human-readable" as feasible to
be a useful tool for site admins. They can be transformed to values of
be_
properites (and back).
Note
For the moment, refer to the role export in the Backend Module. The in-depth documentation of this format transformation is yet to be written.
-
Text
This is text only. It will be copied 1:1 to the corresponding field in
be_
.groups -
Array
This array will be stored as comma-separated list in the corresponding field in
be_
.groups -
Multi-Array
This multi-dimensional array will also be stored as comma-separated list in the corresponding field in
be_
. But the formatting is more complex as it stores lots of information.groups
Example: one file per role definition
It is common to have not one but lots of roles. For better overview and maintenance you can easily split the role definitions into multiple files. The "main" file only holds the relevant includes.
Create a directory <project-
. In there add
as much files as needed. Every file can then be included in the "main" file:
imports:
- { resource: './BackendRoleDefinitions/AvdancedEditor.yaml' }
- { resource: './BackendRoleDefinitions/SimpleEditor.yaml' }
RoleDefinitions:
-
identifier: role-editor-advanced
title: '[Role] Advanced editor'
# ...
RoleDefinitions:
-
identifier: role-editor-simple
title: '[Role] Simple editor'
# ...
return [
require __DIR__ . '/BackendRoleDefinitions/AvdancedEditor.php',
require __DIR__ . '/BackendRoleDefinitions/SimpleEditor.php',
];
return [
'identifier' => 'role-editor-advanced',
'title' => '[Role] Advanced editor',
// ...
];
return [
'identifier' => 'role-editor-simple',
'title' => '[Role] Simple editor',
// ...
];