getUser() public method

Returns the user component.
public getUser ( ) : User
return User the user component.
Example #1
0
 /**
  * Returns the log context for a web application
  * @return array
  */
 public function getWebContext(\yii\web\Application $app)
 {
     $request = $app->getRequest();
     $user = $app->getUser();
     return [['title' => 'Remote IP', 'value' => $request->getUserIP(), 'short' => true], ['title' => 'User ID', 'value' => $user->isGuest ? 'Guest' : $user->identity->getId(), 'short' => true], ['title' => 'URL', 'value' => $request->getUrl(), 'short' => true], ['title' => 'Method', 'value' => $request->method, 'short' => true]];
 }