Doctrine/ORM/Filter/Listener/SharingFilterSubscriber.php
private function getUserId()
    {
        $id = null;

        if (null !== $this->tokenStorage && null !== $this->tokenStorage->getToken()) {
            $user = $this->tokenStorage->getToken()->getUser();

            if ($user instanceof UserInterface) {
                $id = $user->getId();
            }
        }

        return $id;
    }
private function getUserId()
    {
        $id = null;

        if (null !== $this->tokenStorage && null !== $this->tokenStorage->getToken()) {
            $user = $this->tokenStorage->getToken()->getUser();

            if ($user instanceof UserInterface) {
                $id = $user->getId();
            }
        }

        return $id;
    }
private function getUserId ( ) { $ id = null ; if ( null !== $ this -> tokenStorage && null !== $ this -> tokenStorage -> getToken ( ) ) { $ user = $ this -> tokenStorage -> getToken ( ) -> getUser ( ) ; if ( $ user instanceof UserInterface ) { $ id = $ user -> getId ( ) ; } } return $ id ; }
Get the current user id.

@return null|int|string
Get the current user id .