Skip to content
PHP Ecosystem
Explore

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.

PropertyTypeDescriptionDefined by
$actionsarray<string, array<string, mixed>|class-string>Standalone actions merged into the debug module’s Module::$actionMap, keyed by action ID. Default: [].yii\debug\Panel
$behaviors read-onlyarray<yii\base\Behavior<static>>List of behaviors attached to this component.yii\base\Component
$detail read-onlystringRendered panel markup.UserPanel
$displayNamestringDisplay name shown in the panel header and the toolbar chip. Default: \PHPForge\Debug\Panel\PanelTitle::USER->value.UserPanel
$filterColumnsarray<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
$filterModelstring|yii\base\Model|nullFilter 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
$idstringPanel unique identifier, assigned by the container module on registration. Default: ''.yii\debug\Panel
$moduleyii\debug\Module|nullDebug module owning this panel. Default: null.yii\debug\Panel
$name read-onlystringPanel display name.UserPanel
$renderContextPHPForge\Debug\Panel\PanelRenderContext|nullPrepared render context, or null outside a debugger request.yii\debug\Panel
$ruleUserSwitcharray<string, mixed>Access-rule definition that decides who can switch user identity. Default: ['allow' => false].UserPanel
$tagstringTag of the request whose data this panel currently exposes. Default: ''.yii\debug\Panel
$toolbarData read-onlyarray<string, mixed>Toolbar envelope; [] to skip the panel.yii\debug\Panel
$toolbarIcon read-onlystringToolbar icon key.UserPanel
$url read-onlystringAbsolute URL to the panel detail view.yii\debug\Panel
$user read-onlyyii\web\User|nullBound user component, or null when the configured id does not resolve to one.UserPanel
$userComponentstring|yii\web\UserComponent id of the user component, or a User instance to operate on directly. Default: 'user'.UserPanel
$userDataProvider read-onlyyii\data\DataProviderInterfaceProvider backing the user-switch grid.UserPanel
$usersFilterModel read-onlyyii\base\Model|nullFilter model instance, or null when it is not configured as one.UserPanel
$userSwitchyii\debug\models\UserSwitch|nullUser-switching model bound on init() once the panel resolves a non-guest identity. Default: null.UserPanel
$viewPath read-onlystringDirectory the panel views resolve against.yii\debug\Panel
$error protectedPHPForge\Debug\Storage\ExceptionSnapshot|nullException captured when the panel failed to produce or hydrate its snapshot. Default: null.yii\debug\Panel
MethodDescriptionDefined by
__construct()Constructor.yii\base\BaseObject
__call()Calls the named method which is not a class method.yii\base\Component
__clone()This method is called after the object is created by cloning an existing one.yii\base\Component
__get()Returns the value of a component property.yii\base\Component
__isset()Checks if a property is set, i.e. defined and not null.yii\base\Component
__set()Sets the value of a component property.yii\base\Component
__unset()Sets a component property to be null.yii\base\Component
attachBehavior()Attaches a behavior to this component.yii\base\Component
attachBehaviors()Attaches a list of behaviors to the component.yii\base\Component
behaviors()Returns a list of behaviors that this component should behave as.yii\base\Component
canGetProperty()Returns a value indicating whether a property can be read.yii\base\Component
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\base\Component
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\debug\Panel
className() staticReturns the fully qualified name of this class.yii\base\BaseObject
detachBehavior()Detaches a behavior from the component.yii\base\Component
detachBehaviors()Detaches all behaviors from the component.yii\base\Component
ensureBehaviors()Makes sure that the behaviors declared in behaviors() are attached to this component.yii\base\Component
getBehavior()Returns the named behavior object.yii\base\Component
getBehaviors()Returns all behaviors attached to this component.yii\base\Component
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\debug\Panel
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\debug\Panel
getToolbarData()Returns the toolbar envelope wrapping the panel’s icon, items, and URL.yii\debug\Panel
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\debug\Panel
getUrl()Returns the URL pointing to this panel’s detail view for the current request tag.yii\debug\Panel
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\debug\Panel
hasContent()Returns whether the panel captured content for the loaded request.yii\debug\Panel
hasError()Returns true when setError() captured an exception during panel capture or hydration.yii\debug\Panel
hasEventHandlers()Returns a value indicating whether there is any handler attached to the named event.yii\base\Component
hasMethod()Returns a value indicating whether a method is defined.yii\base\Component
hasProperty()Returns a value indicating whether a property is defined for this component.yii\base\Component
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\debug\Panel
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\base\Component
on()Attaches an event handler to an event.yii\base\Component
setError()Records an exception thrown during capture or hydration so LogTarget can surface it in the UI.yii\debug\Panel
setRenderContext()Installs the framework-neutral render context prepared for this panel by the debugger action.yii\debug\Panel
trigger()Triggers an event.yii\base\Component
getToolbarItems() protectedBuilds the toolbar item with the active identity id, switching the chip to a warning tone when impersonation is active.UserPanel
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.

public function canSwitchUser(): bool

Returns 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

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.

public function getName(): string

Returns the panel display name (configurable via $displayName).

Returns

string: Panel display name.

public function getToolbarIcon(): string

Returns the icon key from the shared panel icon enum.

Returns

string: Toolbar icon key.

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 instance.

Returns

yii\web\User|null: Bound user component, or null when the configured id does not resolve to one.

Throws

public function getUserDataProvider(): yii\data\DataProviderInterface

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

Returns

yii\data\DataProviderInterface: Provider backing the user-switch grid.

Throws

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|null: Filter model instance, or null when it is not configured as one.

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

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

Parameters

ParameterTypeDescription
$payloadarray<string, mixed>Captured panel payload.

Throws

  • PHPForge\Debug\Storage\HydrationException: when the payload does not match the snapshot schema.
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 explicitly allows it. For a panel instantiated before the module reference exists, the attach is deferred to moduleBound().

Throws

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.

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, 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.

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.