# UserPanel

> Renders the authenticated identity captured by the User collector, optionally allowing the developer to switch to another user.

[API reference](/docs/api/index.md) › [Debug](/docs/extensions/debug/reference/index.md) › [panels](/docs/extensions/debug/reference/panels/index.md) › UserPanel

| class | `yii\debug\panels\UserPanel` |
| --- | --- |
| Extends | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) » [`yii\base\Component`](/docs/api/yii/base/component/index.md) » [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| Implements | [`yii\base\ViewContextInterface`](/docs/api/yii/base/viewcontextinterface/index.md), [`yii\base\Configurable`](/docs/api/yii/base/configurable/index.md) |
| Source | [`src/panels/UserPanel.php`](https://github.com/yii2-extensions/debug/blob/main/src/panels/UserPanel.php#L37) |

Renders the authenticated identity captured by the User collector, optionally allowing the developer to switch to
another user.

Presents the identity's attributes, RBAC roles, and permissions through the detail view with `Reveal` buttons on
sensitive fields; and (when the configured access rule allows) lists candidate identities in a GridView so the
developer can impersonate one with a single click. Data acquisition lives in
[`UserCollector`](/docs/extensions/debug/reference/collectors/usercollector/index.md).

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-actions"></span>[`$actions`](/docs/extensions/debug/reference/panel/index.md#property-actions) | `array<string, array<string, mixed>\|class-string>` | Standalone actions merged into the debug module's [`Module::$actionMap`](/docs/api/yii/base/module/index.md#property-actionMap), keyed by action ID. Default: `[]`. | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |
| <span id="property-behaviors"></span>[`$behaviors`](/docs/api/yii/base/component/index.md#property-behaviors) read-only | `array<`[`yii\base\Behavior`](/docs/api/yii/base/behavior/index.md)`<static>>` | List of behaviors attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="property-detail"></span>`$detail` read-only | `string` | Rendered panel markup. | `UserPanel` |
| <span id="property-displayName"></span>`$displayName` | `string` | Display name shown in the panel header and the toolbar chip. Default: `\PHPForge\Debug\Panel\PanelTitle::USER->value`. | `UserPanel` |
| <span id="property-filterColumns"></span>`$filterColumns` | `array<int\|string, mixed>` | GridView column definitions for the user-switch table. Default: `[['attribute' => 'id', 'headerOptions' => ['class' => 'yii-debug-col-userswitch-id'], 'contentOptions' => ['class' => 'yii-debug-col-userswitch-id']], ['attribute' => 'username', 'headerOptions' => ['class' => 'yii-debug-col-userswitch-username']], ['attribute' => 'email', 'headerOptions' => ['class' => 'yii-debug-col-userswitch-email']], ['attribute' => 'status', 'headerOptions' => ['class' => 'yii-debug-col-userswitch-status'], 'contentOptions' => ['class' => 'yii-debug-col-userswitch-status']], ['attribute' => 'created_at', 'format' => ['datetime', 'php:Y-m-d H:i'], 'headerOptions' => ['class' => 'yii-debug-col-userswitch-timestamp'], 'contentOptions' => ['class' => 'yii-debug-col-userswitch-timestamp']], ['attribute' => 'updated_at', 'format' => ['datetime', 'php:Y-m-d H:i'], 'headerOptions' => ['class' => 'yii-debug-col-userswitch-timestamp'], 'contentOptions' => ['class' => 'yii-debug-col-userswitch-timestamp']]]`. | `UserPanel` |
| <span id="property-filterModel"></span>`$filterModel` | `string\|`[`yii\base\Model`](/docs/api/yii/base/model/index.md)`\|null` | Filter model that powers the user-switch GridView; can be a class-name string, a model instance, or `null` to disable the search affordance. Default: `null`. | `UserPanel` |
| <span id="property-id"></span>[`$id`](/docs/extensions/debug/reference/panel/index.md#property-id) | `string` | Panel unique identifier, assigned by the container module on registration. Default: `''`. | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |
| <span id="property-module"></span>[`$module`](/docs/extensions/debug/reference/panel/index.md#property-module) | [`yii\debug\Module`](/docs/extensions/debug/reference/module/index.md)`\|null` | Debug module owning this panel. Default: `null`. | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |
| <span id="property-name"></span>`$name` read-only | `string` | Panel display name. | `UserPanel` |
| <span id="property-renderContext"></span>[`$renderContext`](/docs/extensions/debug/reference/panel/index.md#property-renderContext) | `PHPForge\Debug\Panel\PanelRenderContext\|null` | Prepared render context, or `null` outside a debugger request. | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |
| <span id="property-ruleUserSwitch"></span>`$ruleUserSwitch` | `array<string, mixed>` | Access-rule definition that decides who can switch user identity. Default: `['allow' => false]`. | `UserPanel` |
| <span id="property-tag"></span>[`$tag`](/docs/extensions/debug/reference/panel/index.md#property-tag) | `string` | Tag of the request whose data this panel currently exposes. Default: `''`. | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |
| <span id="property-toolbarData"></span>[`$toolbarData`](/docs/extensions/debug/reference/panel/index.md#property-toolbarData) read-only | `array<string, mixed>` | Toolbar envelope; `[]` to skip the panel. | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |
| <span id="property-toolbarIcon"></span>`$toolbarIcon` read-only | `string` | Toolbar icon key. | `UserPanel` |
| <span id="property-url"></span>[`$url`](/docs/extensions/debug/reference/panel/index.md#property-url) read-only | `string` | Absolute URL to the panel detail view. | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |
| <span id="property-user"></span>`$user` read-only | [`yii\web\User`](/docs/api/yii/web/user/index.md)`\|null` | Bound user component, or `null` when the configured id does not resolve to one. | `UserPanel` |
| <span id="property-userComponent"></span>`$userComponent` | `string\|`[`yii\web\User`](/docs/api/yii/web/user/index.md) | Component id of the user component, or a [`User`](/docs/api/yii/web/user/index.md) instance to operate on directly. Default: `'user'`. | `UserPanel` |
| <span id="property-userDataProvider"></span>`$userDataProvider` read-only | [`yii\data\DataProviderInterface`](/docs/api/yii/data/dataproviderinterface/index.md) | Provider backing the user-switch grid. | `UserPanel` |
| <span id="property-usersFilterModel"></span>`$usersFilterModel` read-only | [`yii\base\Model`](/docs/api/yii/base/model/index.md)`\|null` | Filter model instance, or `null` when it is not configured as one. | `UserPanel` |
| <span id="property-userSwitch"></span>`$userSwitch` | [`yii\debug\models\UserSwitch`](/docs/extensions/debug/reference/models/userswitch/index.md)`\|null` | User-switching model bound on [`init()`](/docs/extensions/debug/reference/panels/userpanel/index.md#method-init) once the panel resolves a non-guest identity. Default: `null`. | `UserPanel` |
| <span id="property-viewPath"></span>[`$viewPath`](/docs/extensions/debug/reference/panel/index.md#property-viewPath) read-only | `string` | Directory the panel views resolve against. | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |
| <span id="property-error"></span>[`$error`](/docs/extensions/debug/reference/panel/index.md#property-error) protected | `PHPForge\Debug\Storage\ExceptionSnapshot\|null` | Exception captured when the panel failed to produce or hydrate its snapshot. Default: `null`. | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| <span id="method-__construct"></span>[`__construct()`](/docs/api/yii/base/baseobject/index.md#method-__construct) | Constructor. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__call"></span>[`__call()`](/docs/api/yii/base/component/index.md#method-__call) | Calls the named method which is not a class method. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__clone"></span>[`__clone()`](/docs/api/yii/base/component/index.md#method-__clone) | This method is called after the object is created by cloning an existing one. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__get"></span>[`__get()`](/docs/api/yii/base/component/index.md#method-__get) | Returns the value of a component property. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__isset"></span>[`__isset()`](/docs/api/yii/base/component/index.md#method-__isset) | Checks if a property is set, i.e. defined and not null. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__set"></span>[`__set()`](/docs/api/yii/base/component/index.md#method-__set) | Sets the value of a component property. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__unset"></span>[`__unset()`](/docs/api/yii/base/component/index.md#method-__unset) | Sets a component property to be null. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-attachBehavior"></span>[`attachBehavior()`](/docs/api/yii/base/component/index.md#method-attachBehavior) | Attaches a behavior to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-attachBehaviors"></span>[`attachBehaviors()`](/docs/api/yii/base/component/index.md#method-attachBehaviors) | Attaches a list of behaviors to the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-behaviors"></span>[`behaviors()`](/docs/api/yii/base/component/index.md#method-behaviors) | Returns a list of behaviors that this component should behave as. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-canGetProperty"></span>[`canGetProperty()`](/docs/api/yii/base/component/index.md#method-canGetProperty) | Returns a value indicating whether a property can be read. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`canSearchUsers()`](#method-canSearchUsers) | Returns whether the user-switch search affordance is available (the filter model exposes a `search()` method). | `UserPanel` |
| <span id="method-canSetProperty"></span>[`canSetProperty()`](/docs/api/yii/base/component/index.md#method-canSetProperty) | Returns a value indicating whether a property can be set. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`canSwitchUser()`](#method-canSwitchUser) | Returns whether the main (pre-switch) user is allowed to switch identities under [`$ruleUserSwitch`](/docs/extensions/debug/reference/panels/userpanel/index.md#property-ruleUserSwitch). | `UserPanel` |
| <span id="method-capture"></span>[`capture()`](/docs/extensions/debug/reference/panel/index.md#method-capture) | Captures the panel payload for the current request. | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |
| <span id="method-className"></span>[`className()`](/docs/api/yii/base/baseobject/index.md#method-className) static | Returns the fully qualified name of this class. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-detachBehavior"></span>[`detachBehavior()`](/docs/api/yii/base/component/index.md#method-detachBehavior) | Detaches a behavior from the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-detachBehaviors"></span>[`detachBehaviors()`](/docs/api/yii/base/component/index.md#method-detachBehaviors) | Detaches all behaviors from the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-ensureBehaviors"></span>[`ensureBehaviors()`](/docs/api/yii/base/component/index.md#method-ensureBehaviors) | Makes sure that the behaviors declared in [`behaviors()`](/docs/api/yii/base/component/index.md#method-behaviors) are attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-getBehavior"></span>[`getBehavior()`](/docs/api/yii/base/component/index.md#method-getBehavior) | Returns the named behavior object. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-getBehaviors"></span>[`getBehaviors()`](/docs/api/yii/base/component/index.md#method-getBehaviors) | Returns all behaviors attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`getDetail()`](#method-getDetail) | Renders the detail view through the shared declarative presenter, followed by the user-switch form. | `UserPanel` |
| <span id="method-getError"></span>[`getError()`](/docs/extensions/debug/reference/panel/index.md#method-getError) | Returns the exception captured while collecting the panel payload, if any. | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |
| [`getName()`](#method-getName) | Returns the panel display name (configurable via [`$displayName`](/docs/extensions/debug/reference/panels/userpanel/index.md#property-displayName)). | `UserPanel` |
| <span id="method-getRenderContext"></span>[`getRenderContext()`](/docs/extensions/debug/reference/panel/index.md#method-getRenderContext) | Returns the framework-neutral render context for the active debugger request, when one has been prepared. | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |
| <span id="method-getToolbarData"></span>[`getToolbarData()`](/docs/extensions/debug/reference/panel/index.md#method-getToolbarData) | Returns the toolbar envelope wrapping the panel's icon, items, and URL. | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |
| [`getToolbarIcon()`](#method-getToolbarIcon) | Returns the icon key from the shared panel icon enum. | `UserPanel` |
| <span id="method-getTraceLine"></span>[`getTraceLine()`](/docs/extensions/debug/reference/panel/index.md#method-getTraceLine) | Builds a trace line for the toolbar through the shared [`Trace`](https://github.com/php-forge/debug-core/blob/b70459f033a1d7a1c5edf7951029aad2061986dd/src/Helper/Trace.php) renderer, applying [`Module::$tracePathMappings`](/docs/extensions/debug/reference/module/index.md#property-tracePathMappings) and the configured [`Module::$traceLine`](/docs/extensions/debug/reference/module/index.md#property-traceLine) template (or callable). | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |
| <span id="method-getUrl"></span>[`getUrl()`](/docs/extensions/debug/reference/panel/index.md#method-getUrl) | Returns the URL pointing to this panel's detail view for the current request tag. | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |
| [`getUser()`](#method-getUser) | Returns the user component bound to this panel, or `null` when the configured component id does not resolve to a [`User`](/docs/api/yii/web/user/index.md) instance. | `UserPanel` |
| [`getUserDataProvider()`](#method-getUserDataProvider) | Returns the data provider that backs the user-switch GridView. | `UserPanel` |
| [`getUsersFilterModel()`](#method-getUsersFilterModel) | Returns the filter model instance for the GridView, or `null` when the filter model is not configured as an instance. | `UserPanel` |
| <span id="method-getViewPath"></span>[`getViewPath()`](/docs/extensions/debug/reference/panel/index.md#method-getViewPath) | Returns the directory under which the panel's relative views resolve. | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |
| <span id="method-hasContent"></span>[`hasContent()`](/docs/extensions/debug/reference/panel/index.md#method-hasContent) | Returns whether the panel captured content for the loaded request. | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |
| <span id="method-hasError"></span>[`hasError()`](/docs/extensions/debug/reference/panel/index.md#method-hasError) | Returns `true` when [`setError()`](/docs/extensions/debug/reference/panel/index.md#method-setError) captured an exception during panel capture or hydration. | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |
| <span id="method-hasEventHandlers"></span>[`hasEventHandlers()`](/docs/api/yii/base/component/index.md#method-hasEventHandlers) | Returns a value indicating whether there is any handler attached to the named event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-hasMethod"></span>[`hasMethod()`](/docs/api/yii/base/component/index.md#method-hasMethod) | Returns a value indicating whether a method is defined. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-hasProperty"></span>[`hasProperty()`](/docs/api/yii/base/component/index.md#method-hasProperty) | Returns a value indicating whether a property is defined for this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`hydrate()`](#method-hydrate) | Decodes the captured payload into the typed identity snapshot backing this panel. | `UserPanel` |
| [`init()`](#method-init) | Wires the user-switch model and the deny-by-default access rules for the switch actions, then adds the search filter model when the user component resolves to a non-guest identity. | `UserPanel` |
| [`isEnabled()`](#method-isEnabled) | Returns whether the user component is resolvable; the panel is harmless on apps with no user component. | `UserPanel` |
| <span id="method-isVisible"></span>[`isVisible()`](/docs/extensions/debug/reference/panel/index.md#method-isVisible) | Returns whether the panel should appear in the toolbar and sidebar navigation. | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |
| [`moduleBound()`](#method-moduleBound) | Attaches the user-switch access rules once the debug module binds itself to the panel. | `UserPanel` |
| <span id="method-off"></span>[`off()`](/docs/api/yii/base/component/index.md#method-off) | Detaches an existing event handler from this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-on"></span>[`on()`](/docs/api/yii/base/component/index.md#method-on) | Attaches an event handler to an event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-setError"></span>[`setError()`](/docs/extensions/debug/reference/panel/index.md#method-setError) | Records an exception thrown during capture or hydration so [`LogTarget`](/docs/extensions/debug/reference/logtarget/index.md) can surface it in the UI. | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |
| <span id="method-setRenderContext"></span>[`setRenderContext()`](/docs/extensions/debug/reference/panel/index.md#method-setRenderContext) | Installs the framework-neutral render context prepared for this panel by the debugger action. | [`yii\debug\Panel`](/docs/extensions/debug/reference/panel/index.md) |
| <span id="method-trigger"></span>[`trigger()`](/docs/api/yii/base/component/index.md#method-trigger) | Triggers an event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`getToolbarItems()`](#method-getToolbarItems) protected | Builds the toolbar item with the active identity id, switching the chip to a `warning` tone when impersonation is active. | `UserPanel` |

## Method details

### canSearchUsers() <span id="method-canSearchUsers"></span>

```php
public function canSearchUsers(): bool
```

Returns whether the user-switch search affordance is available (the filter model exposes a `search()` method).

**Returns**

`bool`: `true` when the filter model exposes a search; `false` otherwise.

### canSwitchUser() <span id="method-canSwitchUser"></span>

```php
public function canSwitchUser(): bool
```

Returns whether the main (pre-switch) user is allowed to switch identities under [`$ruleUserSwitch`](/docs/extensions/debug/reference/panels/userpanel/index.md#property-ruleUserSwitch).

**Returns**

`bool`: `true` when the main user may switch identities; `false` otherwise.

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): when the debug module or the user component cannot be resolved.

### getDetail() <span id="method-getDetail"></span>

```php
public function getDetail(): string
```

Renders the detail view through the shared declarative presenter, followed by the user-switch form.

The switch form stays here because it is an interactive Yii widget the framework-neutral presenter cannot
describe.

**Returns**

`string`: Rendered panel markup.

### getName() <span id="method-getName"></span>

```php
public function getName(): string
```

Returns the panel display name (configurable via [`$displayName`](/docs/extensions/debug/reference/panels/userpanel/index.md#property-displayName)).

**Returns**

`string`: Panel display name.

### getToolbarIcon() <span id="method-getToolbarIcon"></span>

```php
public function getToolbarIcon(): string
```

Returns the icon key from the shared panel icon enum.

**Returns**

`string`: Toolbar icon key.

### getUser() <span id="method-getUser"></span>

```php
public function getUser(): yii\web\User|null
```

Returns the user component bound to this panel, or `null` when the configured component id does not resolve to
a [`User`](/docs/api/yii/web/user/index.md) instance.

**Returns**

[`yii\web\User`](/docs/api/yii/web/user/index.md)`|null`: Bound user component, or `null` when the configured id does not resolve to one.

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): when the configured component cannot be retrieved from the application.

### getUserDataProvider() <span id="method-getUserDataProvider"></span>

```php
public function getUserDataProvider(): yii\data\DataProviderInterface
```

Returns the data provider that backs the user-switch GridView.

**Returns**

[`yii\data\DataProviderInterface`](/docs/api/yii/data/dataproviderinterface/index.md): Provider backing the user-switch grid.

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): when the filter model does not implement [`UserSearchInterface`](/docs/extensions/debug/reference/models/search/usersearchinterface/index.md).

### getUsersFilterModel() <span id="method-getUsersFilterModel"></span>

```php
public function getUsersFilterModel(): yii\base\Model|null
```

Returns the filter model instance for the GridView, or `null` when the filter model is not configured as an
instance.

**Returns**

[`yii\base\Model`](/docs/api/yii/base/model/index.md)`|null`: Filter model instance, or `null` when it is not configured as one.

### hydrate() <span id="method-hydrate"></span>

```php
public function hydrate(array<string, mixed> $payload): void
```

Decodes the captured payload into the typed identity snapshot backing this panel.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$payload` | `array<string, mixed>` | Captured panel payload. |

**Throws**

- `PHPForge\Debug\Storage\HydrationException`: when the payload does not match the snapshot schema.

### init() <span id="method-init"></span>

```php
public function init(): void
```

Wires the user-switch model and the deny-by-default access rules for the switch actions, then adds the search
filter model when the user component resolves to a non-guest identity.

The access rules attach even for a guest, so an unauthenticated request cannot reach `set-identity` or
`reset-identity` unless the configured [`$ruleUserSwitch`](/docs/extensions/debug/reference/panels/userpanel/index.md#property-ruleUserSwitch) explicitly allows it. For a panel instantiated
before the module reference exists, the attach is deferred to [`moduleBound()`](/docs/extensions/debug/reference/panels/userpanel/index.md#method-moduleBound).

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): when the user component cannot be resolved or the filter model cannot be created.

### isEnabled() <span id="method-isEnabled"></span>

```php
public function isEnabled(): bool
```

Returns whether the user component is resolvable; the panel is harmless on apps with no user component.

**Returns**

`bool`: `true` when a user component resolves; `false` otherwise.

### moduleBound() <span id="method-moduleBound"></span>

```php
public function moduleBound(): void
```

Attaches the user-switch access rules once the debug module binds itself to the panel.

When the panel is configured as a prebuilt instance in [`Module::$panels`](/docs/extensions/debug/reference/module/index.md#property-panels), [`init()`](/docs/extensions/debug/reference/panels/userpanel/index.md#method-init) runs
before the module reference exists and skips the attach; this hook closes that gap so `set-identity` and
`reset-identity` stay gated by [`$ruleUserSwitch`](/docs/extensions/debug/reference/panels/userpanel/index.md#property-ruleUserSwitch).

### getToolbarItems() <span id="method-getToolbarItems"></span>

```php
protected function getToolbarItems(): array<int, array<string, mixed>>
```

Builds the toolbar item with the active identity id, switching the chip to a `warning` tone when impersonation
is active.

**Returns**

`array<int, array<string, mixed>>`: Single-element list with the user chip.