protected function addOriginToTargetUrl($target)
    {
        $origin = $this->request->getFullRoute();
        $additionalQuery = '_origin=' . base64_encode($origin);
        
        $parts = parse_url($target);
        
        if ($parts === false) {
            return $target;
        }
        
        if (!isset($parts['query'])) {
            $parts['query'] = '';
        } else if ($parts['query'] !== '') {
            $parts['query'] .= '&';
        }
        
        $parts['query'] .= $additionalQuery;
        return $this->buildUrl($parts);
    }