RoleTypeRegistry
Registry for role types and their options (label, hierarchy, bound memberable model). Used to validate role type values and resolve membership default-role scope.
Namespace
JobMetric\Rolix\Support\RoleTypeRegistry
Facade
use JobMetric\Rolix\Facades\RoleTypeRegistry;
Boot
Types from config('rolix.types') are registered in RolixServiceProvider::afterRegisterPackage.
Options
| Key | Type | Description |
|---|---|---|
label | string | Translation key or label |
description | string | Translation key or description |
hierarchical | bool | Whether parent/child roles are allowed |
model | string|null | Memberable FQCN; omit for system types |
Methods
register()
public function register(string $type, array $options = []): self
Creates or merges options for a type.
RoleTypeRegistry::register('tenant', [
'model' => \App\Models\Tenant::class,
'hierarchical' => true,
'label' => 'Tenant',
]);
unregister()
public function unregister(string $type): self
has() / get() / all() / values()
RoleTypeRegistry::has('tenant'); // bool
RoleTypeRegistry::get('tenant'); // ?array options
RoleTypeRegistry::all(); // array<string, array>
RoleTypeRegistry::values(); // list of type names
getOption()
public function getOption(string $type, string $key, mixed $default = null): mixed
RoleTypeRegistry::getOption('tenant', 'hierarchical', false);
getModel() / isSystem()
RoleTypeRegistry::getModel('tenant'); // Tenant::class or null
RoleTypeRegistry::isSystem('system'); // true when no model
ensure()
public function ensure(string $type): self
Throws: RoleTypeNotFoundException if missing.
Used by Role tree APIs and PermissionManager type trees.
clear()
Removes all registered types (mainly for tests).