Bolt\Users::getCurrentUser PHP Method

getCurrentUser() public method

Get the current user as an array.
public getCurrentUser ( ) : array
return array
    public function getCurrentUser()
    {
        if ($this->currentuser === null) {
            $this->currentuser = $this->app['session']->isStarted() ? $this->app['session']->get('authentication') : null;
            if ($this->currentuser instanceof AccessControl\Token\Token) {
                $this->currentuser = $this->currentuser->getUser()->toArray();
            }
        }
        return $this->currentuser;
    }

Usage Example

Example #1
0
 /**
  * {@inheritdoc}
  */
 public function dump(\Twig_Environment $env, $context)
 {
     // Return if 'debug' is `false` in Twig, or there's no logged on user _and_ `debug_show_loggedoff` in
     // config.yml is `false`.
     if (!$env->isDebug() || $this->users->getCurrentUser() === null && !$this->debugShowLoggedoff) {
         return null;
     }
     if (func_num_args() === 2) {
         $vars = [];
         foreach ($context as $key => $value) {
             if (!$value instanceof \Twig_Template) {
                 $vars[$key] = $value;
             }
         }
         $vars = [$vars];
     } else {
         $vars = func_get_args();
         unset($vars[0], $vars[1]);
     }
     $output = fopen('php://memory', 'r+b');
     $prevOutput = $this->dumper->setOutput($output);
     foreach ($vars as $value) {
         $this->dumper->dump($this->cloner->cloneVar($value));
     }
     $this->dumper->setOutput($prevOutput);
     rewind($output);
     return stream_get_contents($output);
 }
All Usage Examples Of Bolt\Users::getCurrentUser