src/Sulu/Bundle/DocumentManagerBundle/Document/Subscriber/SecuritySubscriber.php
public function setDefaultUser(ConfigureOptionsEvent $event)
    {
        $optionsResolver = $event->getOptions();

        $optionsResolver->setDefault(static::USER_OPTION, null);

        if (null === $this->tokenStorage) {
            return;
        }

        $token = $this->tokenStorage->getToken();

        if (null === $token || $token instanceof AnonymousToken) {
            return;
        }

        $user = $token->getUser();

        if (!$user instanceof UserInterface) {
            return;
        }

        $optionsResolver->setDefault(static::USER_OPTION, $user->getId());
    }
public function setDefaultUser(ConfigureOptionsEvent $event)
    {
        $optionsResolver = $event->getOptions();

        $optionsResolver->setDefault(static::USER_OPTION, null);

        if (null === $this->tokenStorage) {
            return;
        }

        $token = $this->tokenStorage->getToken();

        if (null === $token || $token instanceof AnonymousToken) {
            return;
        }

        $user = $token->getUser();

        if (!$user instanceof UserInterface) {
            return;
        }

        $optionsResolver->setDefault(static::USER_OPTION, $user->getId());
    }
public function setDefaultUser ( ConfigureOptionsEvent $ event ) { $ optionsResolver = $ event -> getOptions ( ) ; $ optionsResolver -> setDefault ( static :: USER_OPTION , null ) ; if ( null === $ this -> tokenStorage ) { return ; } $ token = $ this -> tokenStorage -> getToken ( ) ; if ( null === $ token || $ token instanceof AnonymousToken ) { return ; } $ user = $ token -> getUser ( ) ; if ( ! $ user instanceof UserInterface ) { return ; } $ optionsResolver -> setDefault ( static :: USER_OPTION , $ user -> getId ( ) ) ; }
Sets the default user from the session.

@param ConfigureOptionsEvent $event
Sets the default user from the session .