/** * Returns the "on success" response for the given GuardAuthenticator. * * @param TokenInterface $token * @param Request $request * @param GuardAuthenticatorInterface $guardAuthenticator * @param string $providerKey The provider (i.e. firewall) key * * @return null|Response */ public function handleAuthenticationSuccess(TokenInterface $token, Request $request, GuardAuthenticatorInterface $guardAuthenticator, $providerKey) { $response = $guardAuthenticator->onAuthenticationSuccess($request, $token, $providerKey); // check that it's a Response or null if ($response instanceof Response || null === $response) { return $response; } throw new \UnexpectedValueException(sprintf('The %s::onAuthenticationSuccess method must return null or a Response object. You returned %s.', get_class($guardAuthenticator), is_object($response) ? get_class($response) : gettype($response))); }