/** * Constructor. * * @param ContainerInterface|LogoutUrlGenerator $generator A ContainerInterface or LogoutUrlGenerator instance * @param UrlGeneratorInterface|null $router The router service * @param TokenStorageInterface|null $tokenStorage The token storage service * * @deprecated Passing a ContainerInterface as a first argument is deprecated since 2.7 and will be removed in 3.0. * @deprecated Passing a second and third argument is deprecated since 2.7 and will be removed in 3.0. */ public function __construct($generator, UrlGeneratorInterface $router = null, TokenStorageInterface $tokenStorage = null) { if ($generator instanceof ContainerInterface) { @trigger_error('The ' . __CLASS__ . ' constructor will require a LogoutUrlGenerator instead of a ContainerInterface instance in 3.0.', E_USER_DEPRECATED); if ($generator->has('security.logout_url_generator')) { $this->generator = $generator->get('security.logout_url_generator'); } else { $this->generator = new LogoutUrlGenerator($generator->get('request_stack'), $router, $tokenStorage); } } else { $this->generator = $generator; } }
public function getLogoutPath(Request $request) { foreach ($this->map as $contextId => $requestMatcher) { if (null === $requestMatcher || $requestMatcher->matches($request)) { $key = str_replace('security.firewall.map.context.', '', $contextId, $count); if (!$count) { throw new \InvalidArgumentException('Not found '); } return $this->logout->getLogoutPath($key); } } return '/logout'; }