protected function getCurrentUserIdentity()
    {
        /** @var AccountManagerInterface $manager */
        /** @var PassportAccountInterface $account */
        $manager = $this->getContainer()->get(AccountManagerInterface::class);
        $account = $manager->getAccount();
        $userId  = $account->getUserIdentity();

        return $userId;
    }
protected function getCurrentUserIdentity()
    {
        /** @var AccountManagerInterface $manager */
        /** @var PassportAccountInterface $account */
        $manager = $this->getContainer()->get(AccountManagerInterface::class);
        $account = $manager->getAccount();
        $userId  = $account->getUserIdentity();

        return $userId;
    }
protected function getCurrentUserIdentity ( ) { /** @var AccountManagerInterface $manager */ /** @var PassportAccountInterface $account */ $ manager = $ this -> getContainer ( ) -> get ( AccountManagerInterface :: class ) ; $ account = $ manager -> getAccount ( ) ; $ userId = $ account -> getUserIdentity ( ) ; return $ userId ; }
The method assumes an account is signed in and therefore has less checks.

@return int|string|null

@throws ContainerExceptionInterface
@throws NotFoundExceptionInterface
The method assumes an account is signed in and therefore has less checks .