getTargetPath example

class TestClassWithTargetPathTrait
{
    use TargetPathTrait;

    public function doSetTargetPath(SessionInterface $session$firewallName$uri)
    {
        $this->saveTargetPath($session$firewallName$uri);
    }

    public function doGetTargetPath(SessionInterface $session$firewallName)
    {
        return $this->getTargetPath($session$firewallName);
    }

    public function doRemoveTargetPath(SessionInterface $session$firewallName)
    {
        $this->removeTargetPath($session$firewallName);
    }
}
$targetUrl = ParameterBagUtils::getRequestParameterValue($request$this->options['target_path_parameter']);

        if (\is_string($targetUrl) && (str_starts_with($targetUrl, '/') || str_starts_with($targetUrl, 'http'))) {
            return $targetUrl;
        }

        if ($this->logger && $targetUrl) {
            $this->logger->debug(sprintf('Ignoring query parameter "%s": not a valid URL.', $this->options['target_path_parameter']));
        }

        $firewallName = $this->getFirewallName();
        if (null !== $firewallName && !$request->attributes->getBoolean('_stateless') && $targetUrl = $this->getTargetPath($request->getSession()$firewallName)) {
            $this->removeTargetPath($request->getSession()$firewallName);

            return $targetUrl;
        }

        if ($this->options['use_referer'] && $targetUrl = $request->headers->get('Referer')) {
            if (false !== $pos = strpos($targetUrl, '?')) {
                $targetUrl = substr($targetUrl, 0, $pos);
            }
            if ($targetUrl && $targetUrl !== $this->httpUtils->generateUri($request$this->options['login_path'])) {
                return $targetUrl;
            }
Home | Imprint | This part of the site doesn't use cookies.