RoleLabelTrait
Single place that decides how a role is named in the admin: role list, role select in the user form, group privilege matrix and account header.
System roles (guest, registrated, admin, owner, receiver) have name and description in the
translations admin.system.rbacRoles.<code>.{name,description} (app/Locale/system/*), because
cms_system_user_roles.name is plain text without translations. A role without a translation
(an operator's own role, e.g. "audit tester") keeps its name from the DB.
IMPORTANT: never pass a DB value to the translator as a key. Only the role code comes from the DB, and
it is used to compose a key only after checking its shape and that the key exists in the catalog;
the translator would return a missing key as bare text. The DB name is returned as a ready string,
so callers must not translate it again (setTranslator(null) / NotTranslate / ->translate = false).
The presenter must have $this->translator (TranslatorInitTrait).
Table of Contents
Methods
- roleDescription() : string|null
- Short description of a system role, or `null` when the role has no translation.
- roleLabel() : string
- Human-readable role name: translation of a system role, otherwise the DB name (`$dbName`), otherwise the code.
- roleText() : string|null
- Translation of `admin.system.rbacRoles.<code>.<part>`, or `null` (unknown code shape / key not in the catalog).
Methods
roleDescription()
Short description of a system role, or `null` when the role has no translation.
protected
roleDescription(string $code) : string|null
Parameters
- $code : string
Return values
string|nullroleLabel()
Human-readable role name: translation of a system role, otherwise the DB name (`$dbName`), otherwise the code.
protected
roleLabel(string $code[, string|null $dbName = null ]) : string
Parameters
- $code : string
- $dbName : string|null = null
Return values
stringroleText()
Translation of `admin.system.rbacRoles.<code>.<part>`, or `null` (unknown code shape / key not in the catalog).
private
roleText(string $code, string $part) : string|null
Parameters
- $code : string
- $part : string