UserPanel
API reference › Debug › panels › UserPanel
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.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$actions | array<string, | Standalone actions merged into the debug module’s Module::$actionMap, keyed by action ID. Default: []. | yii\ |
$behaviors read-only | array<yii\<static>> | List of behaviors attached to this component. | yii\ |
$detail read-only | string | Rendered panel markup. | UserPanel |
$displayName | string | Display name shown in the panel header and the toolbar chip. Default: \. | UserPanel |
$filterColumns | array<int| | GridView column definitions for the user-switch table. Default: [['attribute' => 'id',. | UserPanel |
$filterModel | string|yii\| | 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 |
$id | string | Panel unique identifier, assigned by the container module on registration. Default: ''. | yii\ |
$module | yii\| | Debug module owning this panel. Default: null. | yii\ |
$name read-only | string | Panel display name. | UserPanel |
$renderContext | PHPForge\ | Prepared render context, or null outside a debugger request. | yii\ |
$ruleUserSwitch | array<string, | Access-rule definition that decides who can switch user identity. Default: ['allow' => false]. | UserPanel |
$tag | string | Tag of the request whose data this panel currently exposes. Default: ''. | yii\ |
$toolbarData read-only | array<string, | Toolbar envelope; [] to skip the panel. | yii\ |
$toolbarIcon read-only | string | Toolbar icon key. | UserPanel |
$url read-only | string | Absolute URL to the panel detail view. | yii\ |
$user read-only | yii\| | Bound user component, or null when the configured id does not resolve to one. | UserPanel |
$userComponent | string|yii\ | Component id of the user component, or a User instance to operate on directly. Default: 'user'. | UserPanel |
$userDataProvider read-only | yii\ | Provider backing the user-switch grid. | UserPanel |
$usersFilterModel read-only | yii\| | Filter model instance, or null when it is not configured as one. | UserPanel |
$userSwitch | yii\| | User-switching model bound on init() once the panel resolves a non-guest identity. Default: null. | UserPanel |
$viewPath read-only | string | Directory the panel views resolve against. | yii\ |
$error protected | PHPForge\ | Exception captured when the panel failed to produce or hydrate its snapshot. Default: null. | yii\ |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Constructor. | yii\ |
__call() | Calls the named method which is not a class method. | yii\ |
__clone() | This method is called after the object is created by cloning an existing one. | yii\ |
__get() | Returns the value of a component property. | yii\ |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\ |
__set() | Sets the value of a component property. | yii\ |
__unset() | Sets a component property to be null. | yii\ |
attachBehavior() | Attaches a behavior to this component. | yii\ |
attachBehaviors() | Attaches a list of behaviors to the component. | yii\ |
behaviors() | Returns a list of behaviors that this component should behave as. | yii\ |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\ |
canSearchUsers() | Returns whether the user-switch search affordance is available (the filter model exposes a search() method). | UserPanel |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\ |
canSwitchUser() | Returns whether the main (pre-switch) user is allowed to switch identities under $ruleUserSwitch. | UserPanel |
capture() | Captures the panel payload for the current request. | yii\ |
className() static | Returns the fully qualified name of this class. | yii\ |
detachBehavior() | Detaches a behavior from the component. | yii\ |
detachBehaviors() | Detaches all behaviors from the component. | yii\ |
ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\ |
getBehavior() | Returns the named behavior object. | yii\ |
getBehaviors() | Returns all behaviors attached to this component. | yii\ |
getDetail() | Renders the detail view through the shared declarative presenter, followed by the user-switch form. | UserPanel |
getError() | Returns the exception captured while collecting the panel payload, if any. | yii\ |
getName() | Returns the panel display name (configurable via $displayName). | UserPanel |
getRenderContext() | Returns the framework-neutral render context for the active debugger request, when one has been prepared. | yii\ |
getToolbarData() | Returns the toolbar envelope wrapping the panel’s icon, items, and URL. | yii\ |
getToolbarIcon() | Returns the icon key from the shared panel icon enum. | UserPanel |
getTraceLine() | Builds a trace line for the toolbar through the shared Trace renderer, applying Module::$tracePathMappings and the configured Module::$traceLine template (or callable). | yii\ |
getUrl() | Returns the URL pointing to this panel’s detail view for the current request tag. | yii\ |
getUser() | Returns the user component bound to this panel, or null when the configured component id does not resolve to a User instance. | UserPanel |
getUserDataProvider() | Returns the data provider that backs the user-switch GridView. | UserPanel |
getUsersFilterModel() | Returns the filter model instance for the GridView, or null when the filter model is not configured as an instance. | UserPanel |
getViewPath() | Returns the directory under which the panel’s relative views resolve. | yii\ |
hasContent() | Returns whether the panel captured content for the loaded request. | yii\ |
hasError() | Returns true when setError() captured an exception during panel capture or hydration. | yii\ |
hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. | yii\ |
hasMethod() | Returns a value indicating whether a method is defined. | yii\ |
hasProperty() | Returns a value indicating whether a property is defined for this component. | yii\ |
hydrate() | Decodes the captured payload into the typed identity snapshot backing this panel. | UserPanel |
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() | Returns whether the user component is resolvable; the panel is harmless on apps with no user component. | UserPanel |
isVisible() | Returns whether the panel should appear in the toolbar and sidebar navigation. | yii\ |
moduleBound() | Attaches the user-switch access rules once the debug module binds itself to the panel. | UserPanel |
off() | Detaches an existing event handler from this component. | yii\ |
on() | Attaches an event handler to an event. | yii\ |
setError() | Records an exception thrown during capture or hydration so LogTarget can surface it in the UI. | yii\ |
setRenderContext() | Installs the framework-neutral render context prepared for this panel by the debugger action. | yii\ |
trigger() | Triggers an event. | yii\ |
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
Section titled “Method details”canSearchUsers()
Section titled “canSearchUsers() ”public function canSearchUsers(): boolReturns 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()
Section titled “canSwitchUser() ”public function canSwitchUser(): boolReturns whether the main (pre-switch) user is allowed to switch identities under $ruleUserSwitch.
Returns
bool: true when the main user may switch identities; false otherwise.
Throws
yii\base\InvalidConfigException: when the debug module or the user component cannot be resolved.
getDetail()
Section titled “getDetail() ”public function getDetail(): stringRenders 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()
Section titled “getName() ”public function getName(): stringReturns the panel display name (configurable via $displayName).
Returns
string: Panel display name.
getToolbarIcon()
Section titled “getToolbarIcon() ”public function getToolbarIcon(): stringReturns the icon key from the shared panel icon enum.
Returns
string: Toolbar icon key.
getUser()
Section titled “getUser() ”public function getUser(): yii\web\User|nullReturns the user component bound to this panel, or null when the configured component id does not resolve to
a User instance.
Returns
yii\web\User|null: Bound user component, or null when the configured id does not resolve to one.
Throws
yii\base\InvalidConfigException: when the configured component cannot be retrieved from the application.
getUserDataProvider()
Section titled “getUserDataProvider() ”public function getUserDataProvider(): yii\data\DataProviderInterfaceReturns the data provider that backs the user-switch GridView.
Returns
yii\data\DataProviderInterface: Provider backing the user-switch grid.
Throws
yii\base\InvalidConfigException: when the filter model does not implementUserSearchInterface.
getUsersFilterModel()
Section titled “getUsersFilterModel() ”public function getUsersFilterModel(): yii\base\Model|nullReturns the filter model instance for the GridView, or null when the filter model is not configured as an
instance.
Returns
yii\base\Model|null: Filter model instance, or null when it is not configured as one.
hydrate()
Section titled “hydrate() ”public function hydrate(array<string, mixed> $payload): voidDecodes the captured payload into the typed identity snapshot backing this panel.
Parameters
| Parameter | Type | Description |
|---|---|---|
$payload | array<string, | Captured panel payload. |
Throws
PHPForge\Debug\Storage\HydrationException: when the payload does not match the snapshot schema.
init()
Section titled “init() ”public function init(): voidWires 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 explicitly allows it. For a panel instantiated
before the module reference exists, the attach is deferred to moduleBound().
Throws
yii\base\InvalidConfigException: when the user component cannot be resolved or the filter model cannot be created.
isEnabled()
Section titled “isEnabled() ”public function isEnabled(): boolReturns 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()
Section titled “moduleBound() ”public function moduleBound(): voidAttaches 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, 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.
getToolbarItems()
Section titled “getToolbarItems() ”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.