Skip to content
PHP Ecosystem
Explore

UserCollector

API reference › Debug › collectors › UserCollector

classyii\debug\collectors\UserCollector
ExtendsCollector
ImplementsCollectorInterface
Sourcesrc/collectors/UserCollector.php

Captures the authenticated identity for the User panel.

PropertyTypeDescriptionDefined by
$moduleyii\debug\Module|nullDebug module supplying the log target and sibling collectors, assigned by the module on registration. Default: null.Collector
$userComponentstring|yii\web\UserComponent id of the user component, or a User instance to operate on directly. Default: 'user'.UserCollector
MethodDescriptionDefined by
capture() finalEncodes the typed snapshot built by the subclass into the payload persisted for the panel.Collector
id()Returns the stable ID pairing this collector with the User panel.UserCollector
instrument()Installs low-level instrumentation as soon as the module registers the collector, before the panels are built.Collector
shutdown() finalDeactivates the collector once, releasing any subscription created by start().Collector
startup() finalActivates the collector once at the start of the request lifecycle.Collector
dataToString() protectedReturns the value when it is already a string, otherwise renders it with VarDumper::export().UserCollector
getLogMessages() protectedReturns the accumulated log messages, optionally filtered by level, category, and exclusion lists.Collector
getLogTarget() protectedReturns the initialized log target of the owning debug module.Collector
getUser() protectedReturns the user component bound to this collector, or null when the configured component id does not resolve to a User instance.UserCollector
identityData() protectedReturns the identity attributes as a string-keyed map suitable for DetailView::$model.UserCollector
isStarted() protectedReturns whether the collector is active for the current request.Collector
snapshot() protectedSnapshots the identity attributes, the RBAC roles, and the permissions for the active user.UserCollector
start() protectedHook invoked once when the collector activates; subclasses subscribe to framework events here.Collector
stop() protectedHook invoked once when the collector deactivates; subclasses detach subscriptions and clear state here.Collector
public function id(): string

Returns the stable ID pairing this collector with the User panel.

Returns

string: Stable collector ID.

protected function dataToString(mixed $data): string

Returns the value when it is already a string, otherwise renders it with VarDumper::export().

Parameters

ParameterTypeDescription
$datamixedCaptured identity value.

Returns

string: Display string for the User panel.

protected function getUser(): yii\web\User|null

Returns the user component bound to this collector, 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.

protected function identityData(yii\web\IdentityInterface $identity): array<string, mixed>

Returns the identity attributes as a string-keyed map suitable for DetailView::$model.

Reads Model::getAttributes() when the identity is a Model; otherwise keeps only public object properties.

Parameters

ParameterTypeDescription
$identityyii\web\IdentityInterfaceActive identity object.

Returns

array<string, mixed>: Attribute map ready to feed the detail view.

protected function snapshot(): PHPForge\Debug\Panel\User\UserSnapshot|null

Snapshots the identity attributes, the RBAC roles, and the permissions for the active user.

Returns

PHPForge\Debug\Panel\User\UserSnapshot|null: Captured identity or Guest payload; null when the collector never started or the user component cannot be resolved.